You are here

public function ContainerBuilderTest::testAddObjectResource in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testAddObjectResource()

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

File

vendor/symfony/dependency-injection/Tests/ContainerBuilderTest.php, line 543

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testAddObjectResource() {
  $container = new ContainerBuilder();
  $container
    ->setResourceTracking(false);
  $container
    ->addObjectResource(new \BarClass());
  $this
    ->assertEmpty($container
    ->getResources(), 'No resources get registered without resource tracking');
  $container
    ->setResourceTracking(true);
  $container
    ->addObjectResource(new \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()));
}