From 996315ab783803cc09bd4b94c5f3b69095cf402f Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 29 Oct 2017 18:27:31 +0100 Subject: [PATCH 1/5] sort composer.json packages --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index f201f43..795edb9 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,9 @@ ] } }, + "config": { + "sort-packages": true + }, "scripts": { "build": [ "@composer validate --no-check-all", From 7e46bf5f32e9afe2915193137c143266b170d8c5 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 29 Oct 2017 18:27:40 +0100 Subject: [PATCH 2/5] install matthiasnoback/symfony-config-test --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 795edb9..94b86d3 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "require-dev": { "consistence/coding-standard": "2.2.1", "jakub-onderka/php-parallel-lint": "0.9.2", + "matthiasnoback/symfony-config-test": "3.0.1", "phpstan/phpstan-shim": "0.8.4", "phpunit/phpunit": "6.4.3", "satooshi/php-coveralls": "1.0.1" From 49d979029e8706528a67ad793a8154b6b775e887 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 29 Oct 2017 19:34:01 +0100 Subject: [PATCH 3/5] ConfigurationTest --- .../DependencyInjection/ConfigurationTest.php | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tests/DependencyInjection/ConfigurationTest.php diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php new file mode 100644 index 0000000..4735854 --- /dev/null +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,76 @@ +assertConfigurationIsValid( + [ + [], // no values at all + ] + ); + } + + public function testEnabledConfigurationIsValid(): void + { + $this->assertConfigurationIsValid( + [ + [ + 'enabled' => true, + ], + ] + ); + } + + public function testDisabledConfigurationIsValid(): void + { + $this->assertConfigurationIsValid( + [ + [ + 'enabled' => false, + ], + ] + ); + } + + public function testEnabledConfigurationIsValidXX(): void + { + $this->assertConfigurationIsInvalid( + [ + [ + 'enabled' => 1, + ], + ], + 'Invalid type for path "java_script_error_handler.enabled". Expected boolean, but got integer.' + ); + } + + public function testInvalidConfigurationIsInvalid(): void + { + $this->assertConfigurationIsInvalid( + [ + [ + 'invalid_option' => 1, + ], + ], + 'Unrecognized option "invalid_option" under "java_script_error_handler"' + ); + } + + protected function getConfiguration(): ConfigurationInterface + { + return new Configuration(true); + } + +} From 6fa66db83e281d6c02981a3918818332d93fb7b2 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 29 Oct 2017 19:36:06 +0100 Subject: [PATCH 4/5] install matthiasnoback/symfony-dependency-injection-test --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 94b86d3..ebad5e6 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "consistence/coding-standard": "2.2.1", "jakub-onderka/php-parallel-lint": "0.9.2", "matthiasnoback/symfony-config-test": "3.0.1", + "matthiasnoback/symfony-dependency-injection-test": "2.2.0", "phpstan/phpstan-shim": "0.8.4", "phpunit/phpunit": "6.4.3", "satooshi/php-coveralls": "1.0.1" From 689bb5fafa72681a9ebdfc6a8693c6d7b7192028 Mon Sep 17 00:00:00 2001 From: Martin Hujer Date: Sun, 29 Oct 2017 19:45:06 +0100 Subject: [PATCH 5/5] JavaScriptErrorHandlerExtensionTest --- .../JavaScriptErrorHandlerExtensionTest.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/DependencyInjection/JavaScriptErrorHandlerExtensionTest.php diff --git a/tests/DependencyInjection/JavaScriptErrorHandlerExtensionTest.php b/tests/DependencyInjection/JavaScriptErrorHandlerExtensionTest.php new file mode 100644 index 0000000..f497898 --- /dev/null +++ b/tests/DependencyInjection/JavaScriptErrorHandlerExtensionTest.php @@ -0,0 +1,62 @@ +container->setParameter('kernel.debug', true); + + $this->load(); + + $this->assertContainerBuilderHasService(self::LISTENER_CLASS_NAME); + } + + public function testListenerIsNotRegisteredWithoutDebugMode(): void + { + $this->container->setParameter('kernel.debug', false); + + $this->load(); + + $this->assertContainerBuilderNotHasService(self::LISTENER_CLASS_NAME); + } + + public function testKernelDebugCanBeOverriddenToDisable(): void + { + $this->container->setParameter('kernel.debug', true); + + $this->load([ + 'enabled' => false, + ]); + + $this->assertContainerBuilderNotHasService(self::LISTENER_CLASS_NAME); + } + + public function testKernelDebugCanBeOverriddenToEnable(): void + { + $this->container->setParameter('kernel.debug', false); + + $this->load([ + 'enabled' => true, + ]); + + $this->assertContainerBuilderHasService(self::LISTENER_CLASS_NAME); + } + +}