1212namespace Symfony \Component \DependencyInjection \Tests \Extension ;
1313
1414use PHPUnit \Framework \TestCase ;
15+ use Symfony \Component \DependencyInjection \ContainerBuilder ;
16+ use Symfony \Component \DependencyInjection \Extension \Extension ;
1517
1618class ExtensionTest extends TestCase
1719{
@@ -20,36 +22,8 @@ class ExtensionTest extends TestCase
2022 */
2123 public function testIsConfigEnabledReturnsTheResolvedValue ($ enabled )
2224 {
23- $ pb = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag ' )
24- ->setMethods (array ('resolveValue ' ))
25- ->getMock ()
26- ;
27-
28- $ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerBuilder ' )
29- ->setMethods (array ('getParameterBag ' ))
30- ->getMock ()
31- ;
32-
33- $ pb ->expects ($ this ->once ())
34- ->method ('resolveValue ' )
35- ->with ($ this ->equalTo ($ enabled ))
36- ->will ($ this ->returnValue ($ enabled ))
37- ;
38-
39- $ container ->expects ($ this ->once ())
40- ->method ('getParameterBag ' )
41- ->will ($ this ->returnValue ($ pb ))
42- ;
43-
44- $ extension = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\Extension\Extension ' )
45- ->setMethods (array ())
46- ->getMockForAbstractClass ()
47- ;
48-
49- $ r = new \ReflectionMethod ('Symfony\Component\DependencyInjection\Extension\Extension ' , 'isConfigEnabled ' );
50- $ r ->setAccessible (true );
51-
52- $ r ->invoke ($ extension , $ container , array ('enabled ' => $ enabled ));
25+ $ extension = new EnableableExtension ();
26+ $ this ->assertSame ($ enabled , $ extension ->isConfigEnabled (new ContainerBuilder (), array ('enabled ' => $ enabled )));
5327 }
5428
5529 public function getResolvedEnabledFixtures ()
@@ -66,18 +40,20 @@ public function getResolvedEnabledFixtures()
6640 */
6741 public function testIsConfigEnabledOnNonEnableableConfig ()
6842 {
69- $ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerBuilder ' )
70- ->getMock ()
71- ;
43+ $ extension = new EnableableExtension ();
7244
73- $ extension = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\Extension\Extension ' )
74- ->setMethods (array ())
75- ->getMockForAbstractClass ()
76- ;
45+ $ extension ->isConfigEnabled (new ContainerBuilder (), array ());
46+ }
47+ }
7748
78- $ r = new \ReflectionMethod ('Symfony\Component\DependencyInjection\Extension\Extension ' , 'isConfigEnabled ' );
79- $ r ->setAccessible (true );
49+ class EnableableExtension extends Extension
50+ {
51+ public function load (array $ configs , ContainerBuilder $ container )
52+ {
53+ }
8054
81- $ r ->invoke ($ extension , $ container , array ());
55+ public function isConfigEnabled (ContainerBuilder $ container , array $ config )
56+ {
57+ return parent ::isConfigEnabled ($ container , $ config );
8258 }
8359}
0 commit comments