PhpFileLoaderTest.php 1.3 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\PhpFileLoader;
  14. use Symfony\Component\Config\FileLocator;
  15. class PhpFileLoaderTest extends TestCase
  16. {
  17. public function testSupports()
  18. {
  19. $loader = new PhpFileLoader(new ContainerBuilder(), new FileLocator());
  20. $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
  21. $this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
  22. $this->assertTrue($loader->supports('with_wrong_ext.yml', 'php'), '->supports() returns true if the resource with forced type is loadable');
  23. }
  24. public function testLoad()
  25. {
  26. $loader = new PhpFileLoader($container = new ContainerBuilder(), new FileLocator());
  27. $loader->load(__DIR__.'/../Fixtures/php/simple.php');
  28. $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a PHP file resource');
  29. }
  30. }