ClosureLoaderTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Symfony\Tests\Component\DependencyInjection\Loader;
  10. use Symfony\Component\DependencyInjection\ContainerBuilder;
  11. use Symfony\Component\DependencyInjection\Loader\LoaderResolver;
  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. {
  32. $container->setParameter('foo', 'foo');
  33. });
  34. $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a \Closure resource');
  35. }
  36. }