OgGroupContextCacheContextTest.php in Organic groups 8
File
tests/src/Unit/Cache/Context/OgGroupContextCacheContextTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\og\Unit\Cache\Context;
use Drupal\og\Cache\Context\OgGroupContextCacheContext;
class OgGroupContextCacheContextTest extends OgContextCacheContextTestBase {
public function testWithoutContext() {
$this
->expectGroupContext();
$result = $this
->getContextResult();
$this
->assertEquals(OgGroupContextCacheContext::NO_CONTEXT, $result);
}
protected function setupExpectedContext($context) {
if ($context) {
$this->group
->getEntityTypeId()
->willReturn($context['entity_type'])
->shouldBeCalled();
$this->group
->id()
->willReturn($context['id'])
->shouldBeCalled();
$this
->expectGroupContext($this->group
->reveal());
}
else {
$this
->expectGroupContext();
}
}
protected function getCacheContext() {
return new OgGroupContextCacheContext($this->ogContext
->reveal());
}
public function contextProvider() {
return [
[
FALSE,
OgGroupContextCacheContext::NO_CONTEXT,
],
[
[
'entity_type' => 'node',
'id' => 3,
],
'node:3',
],
[
[
'entity_type' => 'entity_test',
'id' => 'Shibo Yangcong-San',
],
'entity_test:Shibo Yangcong-San',
],
];
}
}