PhpFileLoaderTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\Config\Loader\Loader;
  13. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  14. use Symfony\Component\Config\FileLocator;
  15. class PhpFileLoaderTest extends \PHPUnit_Framework_TestCase
  16. {
  17. protected function setUp()
  18. {
  19. if (!class_exists('Symfony\Component\Config\Loader\Loader')) {
  20. $this->markTestSkipped('The "Config" component is not available');
  21. }
  22. }
  23. /**
  24. * @covers Symfony\Component\DependencyInjection\Loader\PhpFileLoader::supports
  25. */
  26. public function testSupports()
  27. {
  28. $loader = new PhpFileLoader(new ContainerBuilder(), new FileLocator());
  29. $this->assertTrue($loader->supports('foo.php'), '->supports() returns true if the resource is loadable');
  30. $this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
  31. }
  32. /**
  33. * @covers Symfony\Component\DependencyInjection\Loader\PhpFileLoader::load
  34. */
  35. public function testLoad()
  36. {
  37. $loader = new PhpFileLoader($container = new ContainerBuilder(), new FileLocator());
  38. $loader->load(__DIR__.'/../Fixtures/php/simple.php');
  39. $this->assertEquals('foo', $container->getParameter('foo'), '->load() loads a PHP file resource');
  40. }
  41. }