You are here

public function ContainerBuilderTest::testAddClassResource in Service Container 7.2

Same name and namespace in other branches
  1. 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testAddClassResource()

@covers Symfony\Component\DependencyInjection\ContainerBuilder::addClassResource

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php, line 570

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testAddClassResource() {
  $container = new ContainerBuilder();
  $container
    ->setResourceTracking(false);
  $container
    ->addClassResource(new \ReflectionClass('BarClass'));
  $this
    ->assertEmpty($container
    ->getResources(), 'No resources get registered without resource tracking');
  $container
    ->setResourceTracking(true);
  $container
    ->addClassResource(new \ReflectionClass('BarClass'));
  $resources = $container
    ->getResources();
  $this
    ->assertCount(1, $resources, '1 resource was registered');

  /* @var $resource \Symfony\Component\Config\Resource\FileResource */
  $resource = end($resources);
  $this
    ->assertInstanceOf('Symfony\\Component\\Config\\Resource\\FileResource', $resource);
  $this
    ->assertSame(realpath(__DIR__ . '/Fixtures/includes/classes.php'), realpath($resource
    ->getResource()));
}