File tree Expand file tree Collapse file tree 3 files changed +143
-0
lines changed
tests/DependencyInjection Expand file tree Collapse file tree 3 files changed +143
-0
lines changed Original file line number Diff line number Diff line change 23
23
"require-dev" : {
24
24
"consistence/coding-standard" : " 2.2.1" ,
25
25
"jakub-onderka/php-parallel-lint" : " 0.9.2" ,
26
+ "matthiasnoback/symfony-config-test" : " 3.0.1" ,
27
+ "matthiasnoback/symfony-dependency-injection-test" : " 2.2.0" ,
26
28
"phpstan/phpstan-shim" : " 0.8.4" ,
27
29
"phpunit/phpunit" : " 6.4.3" ,
28
30
"satooshi/php-coveralls" : " 1.0.1"
44
46
]
45
47
}
46
48
},
49
+ "config" : {
50
+ "sort-packages" : true
51
+ },
47
52
"scripts" : {
48
53
"build" : [
49
54
" @composer validate --no-check-all" ,
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace Mhujer \JavaScriptErrorHandlerBundle \DependencyInjection ;
6
+
7
+ use Matthias \SymfonyConfigTest \PhpUnit \ConfigurationTestCaseTrait ;
8
+ use PHPUnit \Framework \TestCase ;
9
+ use Symfony \Component \Config \Definition \ConfigurationInterface ;
10
+
11
+ class ConfigurationTest extends TestCase
12
+ {
13
+
14
+ use ConfigurationTestCaseTrait;
15
+
16
+ public function testEmptyConfigurationIsValid (): void
17
+ {
18
+ $ this ->assertConfigurationIsValid (
19
+ [
20
+ [], // no values at all
21
+ ]
22
+ );
23
+ }
24
+
25
+ public function testEnabledConfigurationIsValid (): void
26
+ {
27
+ $ this ->assertConfigurationIsValid (
28
+ [
29
+ [
30
+ 'enabled ' => true ,
31
+ ],
32
+ ]
33
+ );
34
+ }
35
+
36
+ public function testDisabledConfigurationIsValid (): void
37
+ {
38
+ $ this ->assertConfigurationIsValid (
39
+ [
40
+ [
41
+ 'enabled ' => false ,
42
+ ],
43
+ ]
44
+ );
45
+ }
46
+
47
+ public function testEnabledConfigurationIsValidXX (): void
48
+ {
49
+ $ this ->assertConfigurationIsInvalid (
50
+ [
51
+ [
52
+ 'enabled ' => 1 ,
53
+ ],
54
+ ],
55
+ 'Invalid type for path "java_script_error_handler.enabled". Expected boolean, but got integer. '
56
+ );
57
+ }
58
+
59
+ public function testInvalidConfigurationIsInvalid (): void
60
+ {
61
+ $ this ->assertConfigurationIsInvalid (
62
+ [
63
+ [
64
+ 'invalid_option ' => 1 ,
65
+ ],
66
+ ],
67
+ 'Unrecognized option "invalid_option" under "java_script_error_handler" '
68
+ );
69
+ }
70
+
71
+ protected function getConfiguration (): ConfigurationInterface
72
+ {
73
+ return new Configuration (true );
74
+ }
75
+
76
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace Mhujer \JavaScriptErrorHandlerBundle \DependencyInjection ;
6
+
7
+ use Matthias \SymfonyDependencyInjectionTest \PhpUnit \AbstractExtensionTestCase ;
8
+ use Mhujer \JavaScriptErrorHandlerBundle \EventListener \JsErrorToAlertListener ;
9
+
10
+ class JavaScriptErrorHandlerExtensionTest extends AbstractExtensionTestCase
11
+ {
12
+
13
+ private const LISTENER_CLASS_NAME = JsErrorToAlertListener::class;
14
+
15
+ protected function getContainerExtensions ()
16
+ {
17
+ return [
18
+ new JavaScriptErrorHandlerExtension (),
19
+ ];
20
+ }
21
+
22
+ public function testListenerIsRegisteredInDebugMode (): void
23
+ {
24
+ $ this ->container ->setParameter ('kernel.debug ' , true );
25
+
26
+ $ this ->load ();
27
+
28
+ $ this ->assertContainerBuilderHasService (self ::LISTENER_CLASS_NAME );
29
+ }
30
+
31
+ public function testListenerIsNotRegisteredWithoutDebugMode (): void
32
+ {
33
+ $ this ->container ->setParameter ('kernel.debug ' , false );
34
+
35
+ $ this ->load ();
36
+
37
+ $ this ->assertContainerBuilderNotHasService (self ::LISTENER_CLASS_NAME );
38
+ }
39
+
40
+ public function testKernelDebugCanBeOverriddenToDisable (): void
41
+ {
42
+ $ this ->container ->setParameter ('kernel.debug ' , true );
43
+
44
+ $ this ->load ([
45
+ 'enabled ' => false ,
46
+ ]);
47
+
48
+ $ this ->assertContainerBuilderNotHasService (self ::LISTENER_CLASS_NAME );
49
+ }
50
+
51
+ public function testKernelDebugCanBeOverriddenToEnable (): void
52
+ {
53
+ $ this ->container ->setParameter ('kernel.debug ' , false );
54
+
55
+ $ this ->load ([
56
+ 'enabled ' => true ,
57
+ ]);
58
+
59
+ $ this ->assertContainerBuilderHasService (self ::LISTENER_CLASS_NAME );
60
+ }
61
+
62
+ }
You can’t perform that action at this time.
0 commit comments