You are here

public function CachedContainerBuilderTest::test_getContainerDefinition in Service Container 7.2

Same name and namespace in other branches
  1. 7 tests/src/DependencyInjection/CachedContainerBuilderTest.php \Drupal\Tests\service_container\DependencyInjection\CachedContainerBuilderTest::test_getContainerDefinition()

Tests that CachedContainerBuilder::getContainerDefinition() works properly. @covers ::getContainerDefinition() @covers ::getCache() @covers ::setCache()

File

tests/src/DependencyInjection/CachedContainerBuilderTest.php, line 73
Contains \Drupal\Tests\service_container\DependencyInjection\CachedContainerBuilderTest

Class

CachedContainerBuilderTest
@coversDefaultClass \Drupal\service_container\DependencyInjection\CachedContainerBuilder @group dic

Namespace

Drupal\Tests\service_container\DependencyInjection

Code

public function test_getContainerDefinition() {
  $fake_definition = $this
    ->getFakeContainerDefinition();

  // It is cached.
  $cached_container_builder = $this
    ->getCachedContainerBuilderMock('service_container:container_definition');
  $this
    ->assertEquals($fake_definition, $cached_container_builder
    ->getContainerDefinition(), 'CachedContainerBuilder definition matches when cached.');

  // It is not cached.
  $uncached_container_builder = $this
    ->getCachedContainerBuilderMock('service_container:miss_container_definition');
  $this
    ->assertEquals($fake_definition, $uncached_container_builder
    ->getContainerDefinition(), 'CachedContainerBuilder definition matches when not cached.');
}