You are here

public function CacheContextsTest::setUp in Render cache 7.2

File

tests/src/Cache/CacheContextsTest.php, line 30
Contains \Drupal\render_cache\Tests\Cache\CacheContextsTest

Class

CacheContextsTest
@coversDefaultClass \Drupal\render_cache\Cache\CacheContexts @group cache

Namespace

Drupal\render_cache\Tests\Cache

Code

public function setUp() {

  // Setup a foo cache context.
  $foo_cache_context = Mockery::mock('\\Drupal\\Core\\Cache\\CacheContextInterface');
  $foo_cache_context
    ->shouldReceive('getLabel')
    ->andReturn('Foo');
  $foo_cache_context
    ->shouldReceive('getContext')
    ->andReturn('bar');

  // Setup a mock container.
  $container = Mockery::mock('alias:Drupal\\service_container\\DependencyInjection\\ContainerInterface');
  $container
    ->shouldReceive('get')
    ->with('cache_context.foo')
    ->andReturn($foo_cache_context);
  $this->cacheContexts = new CacheContexts($container, array(
    'cache_context.foo',
  ));
}