ClosureLoaderTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\DependencyInjection\Loader;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  13. class ClosureLoaderTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @covers Symfony\Component\DependencyInjection\Loader\ClosureLoader::supports
  17. */
  18. public function testSupports()
  19. {
  20. $loader = new ClosureLoader(new ContainerBuilder());
  21. $this->assertTrue($loader->supports(function ($container) {}), '->supports() returns true if the resource is loadable');
  22. $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  23. }
  24. /**
  25. * @covers Symfony\Component\DependencyInjection\Loader\ClosureLoader::load
  26. */
  27. public function testLoad()
  28. {
  29. $loader = new ClosureLoader($container = new ContainerBuilder());
  30. $loader->load(function ($container) {
  31. $container->setParameter('foo', 'foo');
  32. });
  33. $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a \Closure resource');
  34. }
  35. }