diff --git a/.gitignore b/.gitignore index 16fd97f..a5d51fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /composer.lock /vendor/ /.php_cs.cache +/.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index 4cb34e1..95653ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,7 @@ branches: language: php php: - - 7.1 - - 7.2 + - 7.3 - nightly env: @@ -16,13 +15,15 @@ env: matrix: fast_finish: true include: - - php: 7.1 + - php: 7.3 env: COMPOSER_FLAGS="--prefer-lowest" - - php: 7.2 + - php: 7.3 env: SYMFONY_VERSION=3.* - - php: 7.2 + - php: 7.3 env: SYMFONY_VERSION=4.* - - php: 7.2 + - php: 7.3 + env: SYMFONY_VERSION=5.* + - php: 7.3 env: SYMFONY_VERSION=dev-master allow_failures: - php: nightly diff --git a/composer.json b/composer.json index 2e52a87..8bc88aa 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,15 @@ } ], "require": { - "php": "^7.1", - "nexylan/slack": "^2.2", - "php-http/httplug-bundle": "^1.8", - "symfony/http-kernel": "^3.4 || ^4.0" + "php": "^7.3", + "nexylan/slack": "^3.0", + "php-http/httplug-bundle": "^1.17", + "symfony/http-kernel": "^3.4 || ^4.0 || ^5.0" }, "require-dev": { - "matthiasnoback/symfony-dependency-injection-test": "^2.3", + "matthiasnoback/symfony-dependency-injection-test": "^4.0", "php-http/mock-client": "^1.1", - "phpunit/phpunit": "^6.5" + "phpunit/phpunit": "^8.0" }, "suggest": { "eightpoints/guzzle-bundle": "Make a custom Guzzle instance for Slack with ease" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4d1eccc..b715a4b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,8 +8,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" - syntaxCheck="false"> + stopOnFailure="false"> ./tests/ diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2e13fec..1674475 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -38,6 +38,8 @@ public function getConfigTreeBuilder(): TreeBuilder ->addDefaultsIfNotSet() ->children() ->scalarNode('client')->defaultValue('httplug.client')->end() + ->scalarNode('request_factory')->defaultValue('nexy_slack.request_factory.default')->end() + ->scalarNode('stream_factory')->defaultValue('nexy_slack.stream_factory.default')->end() ->end() ->end() ->scalarNode('endpoint') diff --git a/src/DependencyInjection/NexySlackExtension.php b/src/DependencyInjection/NexySlackExtension.php index e2e1854..ce53fba 100644 --- a/src/DependencyInjection/NexySlackExtension.php +++ b/src/DependencyInjection/NexySlackExtension.php @@ -31,6 +31,8 @@ public function load(array $configs, ContainerBuilder $container): void $container->setParameter('nexy_slack.endpoint', $config['endpoint']); $container->setAlias('nexy_slack.http.client', new Alias($config['http']['client'], false)); + $container->setAlias('nexy_slack.http.request_factory', new Alias($config['http']['request_factory'], false)); + $container->setAlias('nexy_slack.http.stream_factory', new Alias($config['http']['stream_factory'], false)); // Unset the not needed keys for the Slack config. unset($config['http'], $config['endpoint']); diff --git a/src/Resources/config/client.xml b/src/Resources/config/client.xml index f4b62f0..4f85e1a 100644 --- a/src/Resources/config/client.xml +++ b/src/Resources/config/client.xml @@ -6,11 +6,21 @@ + + + %nexy_slack.endpoint% %nexy_slack.config% - + + + + + + + + diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 2398ee9..3c753e2 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -16,6 +16,8 @@ use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase; use Nexy\SlackBundle\DependencyInjection\Configuration; use Nexy\SlackBundle\DependencyInjection\NexySlackExtension; +use Symfony\Component\Config\Definition\ConfigurationInterface; +use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; /** * @author Sullivan Senechal @@ -27,6 +29,8 @@ public function testMinimalConfigurationProcess(): void $expectedConfiguration = [ 'http' => [ 'client' => 'httplug.client', + 'request_factory' => 'nexy_slack.request_factory.default', + 'stream_factory' => 'nexy_slack.stream_factory.default', ], 'sticky_channel' => false, 'endpoint' => 'https://hooks.slack.com/services/XXXXX/XXXXX/XXXXXXXXXX', @@ -45,6 +49,8 @@ public function testFullConfigurationProcess(): void $expectedConfiguration = [ 'http' => [ 'client' => 'httplug.curl', + 'request_factory' => 'nexy_slack.request_factory.default', + 'stream_factory' => 'nexy_slack.stream_factory.default', ], 'sticky_channel' => false, 'endpoint' => 'https://hooks.slack.com/services/XXXXX/XXXXX/XXXXXXXXXX', @@ -68,7 +74,7 @@ public function testFullConfigurationProcess(): void /** * {@inheritdoc} */ - protected function getContainerExtension() + protected function getContainerExtension(): ExtensionInterface { return new NexySlackExtension(); } @@ -76,7 +82,7 @@ protected function getContainerExtension() /** * {@inheritdoc} */ - protected function getConfiguration() + protected function getConfiguration(): ConfigurationInterface { return new Configuration(); } diff --git a/tests/DependencyInjection/NexySlackExtensionTest.php b/tests/DependencyInjection/NexySlackExtensionTest.php index 12460a4..6d27ea1 100644 --- a/tests/DependencyInjection/NexySlackExtensionTest.php +++ b/tests/DependencyInjection/NexySlackExtensionTest.php @@ -49,12 +49,16 @@ public function testLoadWithMinimalConfiguration(): void $this->assertContainerBuilderHasService(Client::class); - $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 0, '%nexy_slack.endpoint%'); - $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 1, '%nexy_slack.config%'); - $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 2, new Reference('nexy_slack.http.client')); + $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 0, new Reference('nexy_slack.http.client')); + $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 1, new Reference('nexy_slack.http.request_factory')); + $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 2, new Reference('nexy_slack.http.stream_factory')); + $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 3, '%nexy_slack.endpoint%'); + $this->assertContainerBuilderHasServiceDefinitionWithArgument(Client::class, 4, '%nexy_slack.config%'); $this->assertContainerBuilderHasAlias('nexy_slack.client', Client::class); $this->assertContainerBuilderHasAlias('nexy_slack.http.client', 'httplug.client'); + $this->assertContainerBuilderHasAlias('nexy_slack.http.request_factory', 'nexy_slack.request_factory.default'); + $this->assertContainerBuilderHasAlias('nexy_slack.http.stream_factory', 'nexy_slack.stream_factory.default'); } public function testLoadWithCustomConfiguration(): void @@ -81,7 +85,7 @@ public function testLoadWithCustomConfiguration(): void /** * {@inheritdoc} */ - protected function getContainerExtensions() + protected function getContainerExtensions(): array { return [ new NexySlackExtension(), diff --git a/tests/NexySlackBundleTest.php b/tests/NexySlackBundleTest.php index 6508478..c38173f 100644 --- a/tests/NexySlackBundleTest.php +++ b/tests/NexySlackBundleTest.php @@ -33,6 +33,9 @@ protected function setUp(): void $this->bundle = new NexySlackBundle(); } + /** + * @doesNotPerformAssertions + */ public function testBuild(): void { $this->bundle->build($this->container);