123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Symfony\Component\DependencyInjection\Tests\Extension;
- class ExtensionTest extends \PHPUnit_Framework_TestCase
- {
- /**
- * @dataProvider getResolvedEnabledFixtures
- */
- public function testIsConfigEnabledReturnsTheResolvedValue($enabled)
- {
- $pb = $this->getMockBuilder('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag')
- ->setMethods(array('resolveValue'))
- ->getMock()
- ;
- $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
- ->setMethods(array('getParameterBag'))
- ->getMock()
- ;
- $pb->expects($this->once())
- ->method('resolveValue')
- ->with($this->equalTo($enabled))
- ->will($this->returnValue($enabled))
- ;
- $container->expects($this->once())
- ->method('getParameterBag')
- ->will($this->returnValue($pb))
- ;
- $extension = $this->getMockBuilder('Symfony\Component\DependencyInjection\Extension\Extension')
- ->setMethods(array())
- ->getMockForAbstractClass()
- ;
- $r = new \ReflectionMethod('Symfony\Component\DependencyInjection\Extension\Extension', 'isConfigEnabled');
- $r->setAccessible(true);
- $r->invoke($extension, $container, array('enabled' => $enabled));
- }
- public function getResolvedEnabledFixtures()
- {
- return array(
- array(true),
- array(false)
- );
- }
- /**
- * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
- * @expectedExceptionMessage The config array has no 'enabled' key.
- */
- public function testIsConfigEnabledOnNonEnableableConfig()
- {
- $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
- ->getMock()
- ;
- $extension = $this->getMockBuilder('Symfony\Component\DependencyInjection\Extension\Extension')
- ->setMethods(array())
- ->getMockForAbstractClass()
- ;
- $r = new \ReflectionMethod('Symfony\Component\DependencyInjection\Extension\Extension', 'isConfigEnabled');
- $r->setAccessible(true);
- $r->invoke($extension, $container, array());
- }
- }
|