ClosureLoaderTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Config\Loader\LoaderResolver;
  13. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  14. class ClosureLoaderTest extends \PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @covers Symfony\Component\DependencyInjection\Loader\ClosureLoader::supports
  18. */
  19. public function testSupports()
  20. {
  21. $loader = new ClosureLoader(new ContainerBuilder());
  22. $this->assertTrue($loader->supports(function ($container) {}), '->supports() returns true if the resource is loadable');
  23. $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  24. }
  25. /**
  26. * @covers Symfony\Component\DependencyInjection\Loader\ClosureLoader::load
  27. */
  28. public function testLoad()
  29. {
  30. $loader = new ClosureLoader($container = new ContainerBuilder());
  31. $loader->load(function ($container)
  32. {
  33. $container->setParameter('foo', 'foo');
  34. });
  35. $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a \Closure resource');
  36. }
  37. }