You are here

protected function CachedContainerBuilderTest::getCachedContainerBuilderMock in Service Container 7

Same name and namespace in other branches
  1. 7.2 tests/src/DependencyInjection/CachedContainerBuilderTest.php \Drupal\Tests\service_container\DependencyInjection\CachedContainerBuilderTest::getCachedContainerBuilderMock()
4 calls to CachedContainerBuilderTest::getCachedContainerBuilderMock()
CachedContainerBuilderTest::test_getContainerDefinition in tests/src/DependencyInjection/CachedContainerBuilderTest.php
Tests that CachedContainerBuilder::getContainerDefinition() works properly. @covers ::getContainerDefinition() @covers ::getCache() @covers ::setCache()
CachedContainerBuilderTest::test_isCached in tests/src/DependencyInjection/CachedContainerBuilderTest.php
Tests that CachedContainerBuilder::isCached() works properly. @covers ::__construct() @covers ::isCached() @covers ::getCache()
CachedContainerBuilderTest::test_isCached_getContainerDefinition in tests/src/DependencyInjection/CachedContainerBuilderTest.php
@covers ::isCached() @covers ::getContainerDefinition() @covers ::getCache() @covers ::setCache()
CachedContainerBuilderTest::test_reset in tests/src/DependencyInjection/CachedContainerBuilderTest.php
@covers ::reset()

File

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

Class

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

Namespace

Drupal\Tests\service_container\DependencyInjection

Code

protected function getCachedContainerBuilderMock($cid, $cache = NULL) {
  $fake_definition = $this
    ->getFakeContainerDefinition();
  if (!isset($cache)) {
    if (!isset($this->cache)) {
      $this->cache = $this
        ->setupCache($fake_definition);
    }
    $cache = $this->cache;
  }
  $container_builder = Mockery::mock('\\Drupal\\service_container\\DependencyInjection\\CachedContainerBuilder[getCacheId,moduleAlter]', array(
    $this->serviceProviderManager,
    $cache,
  ));
  $container_builder
    ->shouldAllowMockingProtectedMethods();
  $container_builder
    ->shouldReceive('getCacheId')
    ->andReturn($cid);
  $container_builder
    ->shouldReceive('moduleAlter')
    ->with(Mockery::on(function (&$container_definition) use ($fake_definition) {
    $container_definition['parameters'] = $fake_definition['parameters'];
    $container_definition['services'] = $fake_definition['services'];
    return TRUE;
  }));
  return $container_builder;
}