4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\DependencyInjection\Tests\Extension;
14 use PHPUnit\Framework\TestCase;
16 class ExtensionTest extends TestCase
19 * @dataProvider getResolvedEnabledFixtures
21 public function testIsConfigEnabledReturnsTheResolvedValue($enabled)
23 $pb = $this->getMockBuilder('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag')
24 ->setMethods(array('resolveValue'))
28 $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
29 ->setMethods(array('getParameterBag'))
33 $pb->expects($this->once())
34 ->method('resolveValue')
35 ->with($this->equalTo($enabled))
36 ->will($this->returnValue($enabled))
39 $container->expects($this->once())
40 ->method('getParameterBag')
41 ->will($this->returnValue($pb))
44 $extension = $this->getMockBuilder('Symfony\Component\DependencyInjection\Extension\Extension')
46 ->getMockForAbstractClass()
49 $r = new \ReflectionMethod('Symfony\Component\DependencyInjection\Extension\Extension', 'isConfigEnabled');
50 $r->setAccessible(true);
52 $r->invoke($extension, $container, array('enabled' => $enabled));
55 public function getResolvedEnabledFixtures()
64 * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
65 * @expectedExceptionMessage The config array has no 'enabled' key.
67 public function testIsConfigEnabledOnNonEnableableConfig()
69 $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
73 $extension = $this->getMockBuilder('Symfony\Component\DependencyInjection\Extension\Extension')
75 ->getMockForAbstractClass()
78 $r = new \ReflectionMethod('Symfony\Component\DependencyInjection\Extension\Extension', 'isConfigEnabled');
79 $r->setAccessible(true);
81 $r->invoke($extension, $container, array());