ClosureLoaderTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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\Component\DependencyInjection\Tests\Loader;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  14. class ClosureLoaderTest extends TestCase
  15. {
  16. public function testSupports()
  17. {
  18. $loader = new ClosureLoader(new ContainerBuilder());
  19. $this->assertTrue($loader->supports(function ($container) {}), '->supports() returns true if the resource is loadable');
  20. $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  21. }
  22. public function testLoad()
  23. {
  24. $loader = new ClosureLoader($container = new ContainerBuilder());
  25. $loader->load(function ($container) {
  26. $container->setParameter('foo', 'foo');
  27. });
  28. $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a \Closure resource');
  29. }
  30. }