You've already forked redmine-bundle
Initial commit
This commit is contained in:
8
.editorconfig
Normal file
8
.editorconfig
Normal file
@@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/.phpunit.result.cache
|
||||
/.phpunit.cache
|
||||
/composer.lock
|
||||
/phpunit.xml
|
||||
/vendor/
|
||||
*~
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"nuxt.isNuxtApp": false
|
||||
}
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT license
|
||||
|
||||
Copyright (c) 2021-2022 Marco Grätsch <magdev3.0@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
32
composer.json
Normal file
32
composer.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "magdev/redmine-bundle",
|
||||
"description": "Symfony bundle to integrate Redmine",
|
||||
"type": "symfony-bundle",
|
||||
"require": {
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/http-kernel": "^6.2",
|
||||
"symfony/dependency-injection": "^6.2",
|
||||
"symfony/config": "^6.2",
|
||||
"symfony/phpunit-bridge": "^6.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Magdev\\RedmineBundle\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Magdev\\RedmineBundle\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "magdev",
|
||||
"email": "magdev3.0@gmail.com"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable"
|
||||
}
|
||||
34
phpunit.xml.dist
Normal file
34
phpunit.xml.dist
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="vendor/autoload.php"
|
||||
convertDeprecationsToExceptions="false"
|
||||
>
|
||||
<php>
|
||||
<ini name="display_errors" value="1" />
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<server name="APP_ENV" value="test" force="true" />
|
||||
<server name="SHELL_VERBOSITY" value="-1" />
|
||||
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Project Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
|
||||
<listeners>
|
||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
||||
42
src/DependencyInjection/Configuration.php
Normal file
42
src/DependencyInjection/Configuration.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\RedmineBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class Configuration implements ConfigurationInterface
|
||||
{
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('magdev_gitea');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
$rootNode->fixXmlConfig('connection')
|
||||
->children()
|
||||
->arrayNode('connections')
|
||||
->useAttributeAsKey('name')
|
||||
->normalizeKeys(false)
|
||||
->arrayPrototype()
|
||||
->children()
|
||||
->scalarNode('baseurl')
|
||||
->isRequired()
|
||||
->info('The base URL of the gitea instance')
|
||||
->end()
|
||||
->scalarNode('token')
|
||||
->isRequired()
|
||||
->info('The Gitea access token')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('default_connection')->end()
|
||||
;
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
34
src/DependencyInjection/MagdevRedmineExtension.php
Normal file
34
src/DependencyInjection/MagdevRedmineExtension.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\RedmineBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class MagdevRedmineExtension extends Extension
|
||||
{
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$config = $this->processConfiguration(new Configuration(), $configs);
|
||||
|
||||
/*if (!isset($config['default_connection'])) {
|
||||
$config['default_connection'] = array_key_first($config['connections']);
|
||||
}
|
||||
|
||||
foreach ($config['connections'] as $name => $connection) {
|
||||
$id = sprintf('magdev.gitea.%s', $name);
|
||||
$container->register($id, Client::class)
|
||||
->setArguments([null, null, $connection['baseurl']])
|
||||
->addMethodCall('authenticate', [$connection['token'], null, Client::AUTH_ACCESS_TOKEN]);
|
||||
$container->registerAliasForArgument($id, Client::class, "{$name}Client");
|
||||
|
||||
if ($name === $config['default_connection']) {
|
||||
$container->setAlias(Client::class, $id);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
12
src/MagdevRedmineBundle.php
Normal file
12
src/MagdevRedmineBundle.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Magdev\RedmineBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
final class MagdevRedmineBundle extends Bundle
|
||||
{
|
||||
}
|
||||
41
tests/DependencyInjection/ConfigurationTest.php
Normal file
41
tests/DependencyInjection/ConfigurationTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\RedmineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Magdev\RedmineBundle\DependencyInjection\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider configsProvider
|
||||
*/
|
||||
public function testConfig(array $configs): void
|
||||
{
|
||||
$config = (new Processor())->processConfiguration(new Configuration(), $configs);
|
||||
$this->assertSame('foo', $config['connections']['default']['token']);
|
||||
$this->assertSame('bar', $config['connections']['default']['baseurl']);
|
||||
}
|
||||
|
||||
public function configsProvider(): iterable
|
||||
{
|
||||
yield [
|
||||
[
|
||||
'magdev_redmine' => [
|
||||
'connections' => [
|
||||
'default' => [
|
||||
'token' => 'foo',
|
||||
'baseurl' => 'bar'
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
39
tests/DependencyInjection/MagdevRedmineExtensionTest.php
Normal file
39
tests/DependencyInjection/MagdevRedmineExtensionTest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magdev\RedmineBundle\Tests\DependencyInjection;
|
||||
|
||||
use Magdev\RedmineBundle\DependencyInjection\MagdevRedmineExtension;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* @author Marco Grätsch <magdev3.0@gmail.com>
|
||||
*/
|
||||
class MagdevRedmineExtensionTest extends TestCase
|
||||
{
|
||||
public function testExtension(): void
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
|
||||
(new MagdevRedmineExtension())->load([
|
||||
'magdev_redmine' => [
|
||||
'connections' => [
|
||||
'primary' => ['baseurl' => 'http://foo1', 'token' => 'bar1'],
|
||||
'secondary' => ['baseurl' => 'http://foo2', 'token' => 'bar2'],
|
||||
],
|
||||
],
|
||||
], $container);
|
||||
|
||||
$this->assertTrue($container->has('magdev.redmine.primary'));
|
||||
$this->assertTrue($container->has('magdev.redmine.secondary'));
|
||||
|
||||
$this->assertTrue($container->hasAlias(Client::class));
|
||||
$this->assertTrue($container->hasAlias(Client::class.' $primaryClient'));
|
||||
$this->assertTrue($container->hasAlias(Client::class.' $secondaryClient'));
|
||||
|
||||
$this->assertInstanceOf(Client::class, $container->get('magdev.redmine.primary'));
|
||||
$this->assertInstanceOf(Client::class, $container->get('magdev.redmine.secondary'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user