From 93d2fa6531c116e82ab84cf99117a4a3794bed23 Mon Sep 17 00:00:00 2001 From: magdev Date: Fri, 13 Sep 2024 03:22:19 +0200 Subject: [PATCH] use recent file layout and make this stuff work --- .../Resources/config => config}/services.yaml | 3 +++ src/DependencyInjection/Configuration.php | 21 ------------------- .../MagdevRedmineExtension.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 18 +++++----------- .../MagdevRedmineExtensionTest.php | 5 +---- 5 files changed, 10 insertions(+), 39 deletions(-) rename {src/Resources/config => config}/services.yaml (66%) diff --git a/src/Resources/config/services.yaml b/config/services.yaml similarity index 66% rename from src/Resources/config/services.yaml rename to config/services.yaml index d39e98a..91ec0db 100644 --- a/src/Resources/config/services.yaml +++ b/config/services.yaml @@ -1,3 +1,6 @@ services: Magdev\RedmineBundle\Client\RedmineClient: arguments: ['@redmine_api.cache', '%env(REDMINE_URL)%', '%env(REDMINE_APIKEY)%', '%magdev_redmine.ttl%'] + + magdev_redmine.client: + class: Magdev\RedmineBundle\Client\RedmineClient diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index b5240ba..000eed5 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -21,27 +21,6 @@ final class Configuration implements ConfigurationInterface ->end() ->end(); - #$rootNode->fixXmlConfig('connection') - # ->children() - # ->arrayNode('connections') - # ->useAttributeAsKey('name') - # ->normalizeKeys(false) - # ->arrayPrototype() - # ->children() - # ->scalarNode('url') - # ->isRequired() - # ->info('Base URL of the Redmine instance') - # ->end() - # ->scalarNode('apikey') - # ->isRequired() - # ->info('Redmine API-Key') - # ->end() - # ->end() - # ->end() - # ->end() - # ->scalarNode('default_connection')->end() - #; - return $treeBuilder; } } diff --git a/src/DependencyInjection/MagdevRedmineExtension.php b/src/DependencyInjection/MagdevRedmineExtension.php index 6659583..c90cbcd 100644 --- a/src/DependencyInjection/MagdevRedmineExtension.php +++ b/src/DependencyInjection/MagdevRedmineExtension.php @@ -19,7 +19,7 @@ final class MagdevRedmineExtension extends Extension $container->setParameter('magdev_redmine.ttl', $config['ttl']); - $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new YamlFileLoader($container, new FileLocator(dirname(__DIR__).'/../config')); $loader->load('services.yaml'); } } diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 62ca4a4..a1b48c3 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -17,23 +17,15 @@ class ConfigurationTest extends TestCase public function testConfig(array $configs): void { $config = (new Processor())->processConfiguration(new Configuration(), $configs); - $this->assertSame('foo', $config['connections']['default']['apikey']); - $this->assertSame('bar', $config['connections']['default']['url']); + $this->assertSame(1800, $config['ttl']); } public function configsProvider(): iterable { - yield [ - [ - 'magdev_redmine' => [ - 'connections' => [ - 'default' => [ - 'apikey' => 'foo', - 'url' => 'bar' - ], - ], - ], + yield [[ + 'magdev_redmine' => [ + 'ttl' => 1800 ], - ]; + ]]; } } diff --git a/tests/DependencyInjection/MagdevRedmineExtensionTest.php b/tests/DependencyInjection/MagdevRedmineExtensionTest.php index 89b9b59..6e1b5d3 100644 --- a/tests/DependencyInjection/MagdevRedmineExtensionTest.php +++ b/tests/DependencyInjection/MagdevRedmineExtensionTest.php @@ -18,10 +18,7 @@ class MagdevRedmineExtensionTest extends TestCase (new MagdevRedmineExtension())->load([ 'magdev_redmine' => [ - 'connections' => [ - 'primary' => ['url' => 'http://foo1', 'apikey' => 'bar1'], - 'secondary' => ['url' => 'http://foo2', 'apikey' => 'bar2'], - ], + 'ttl' => 1800, ], ], $container);