You are here

protected function JsonapiMenuItemsTest::assertCacheContext in JSON:API Menu Items 1.2.x

Asserts whether an expected cache context was present in the last response.

Parameters

array $headers: An array of HTTP headers.

string $expected_cache_context: The expected cache context.

5 calls to JsonapiMenuItemsTest::assertCacheContext()
JsonapiMenuItemsTest::testParametersConditions in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'conditions' filter.
JsonapiMenuItemsTest::testParametersMaxDepth in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'max_depth' filter.
JsonapiMenuItemsTest::testParametersMinDepth in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'min_depth' filter.
JsonapiMenuItemsTest::testParametersParent in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'parent' filter.
JsonapiMenuItemsTest::testParametersParents in tests/src/Functional/JsonapiMenuItemsTest.php
Tests the JSON:API Menu Items resource with the 'parents' filter.

File

tests/src/Functional/JsonapiMenuItemsTest.php, line 58

Class

JsonapiMenuItemsTest
Tests JSON:API Menu Items functionality.

Namespace

Drupal\Tests\jsonapi_menu_items\Functional

Code

protected function assertCacheContext(array $headers, $expected_cache_context) {
  $cache_contexts = explode(' ', $headers['X-Drupal-Cache-Contexts'][0]);
  $this
    ->assertTrue(in_array($expected_cache_context, $cache_contexts), "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header.");
}