You are here

public function OgContextCacheContextTestBase::testWithContext in Organic groups 8

Tests the result of the cache context service with active context objects.

This tests the most common use case: the service retrieves data from the active context, and will be able to provide a relevant cache context string in accordance with the provided data.

@covers ::getContext @dataProvider contextProvider

Parameters

mixed $context: Data used to set up the expectations of the context objects. See setupExpectedContext().

string $expected_result: The cache context string which is expected to be returned by the service under test.

File

tests/src/Unit/Cache/Context/OgContextCacheContextTestBase.php, line 61

Class

OgContextCacheContextTestBase
Base class for testing cache contexts that rely on OgContext.

Namespace

Drupal\Tests\og\Unit\Cache\Context

Code

public function testWithContext($context, $expected_result) {
  $this
    ->setupExpectedContext($context);
  $result = $this
    ->getContextResult();
  $this
    ->assertEquals($expected_result, $result);
}