You are here

protected function ViewsDisplayCachingTest::assertCacheMaxAge in Search API 8

Checks if the cache max-age in the given render array is as expected.

Parameters

int $expected_max_age: The max-age value that is expected to be present in the given render array.

array $render_array: The render array of which to check the cache max-age.

Overrides AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge

1 call to ViewsDisplayCachingTest::assertCacheMaxAge()
ViewsDisplayCachingTest::assertViewsCacheability in tests/src/Kernel/Views/ViewsDisplayCachingTest.php
Checks the cacheability metadata of the given view.

File

tests/src/Kernel/Views/ViewsDisplayCachingTest.php, line 301

Class

ViewsDisplayCachingTest
Tests the Search API caching plugins for Views.

Namespace

Drupal\Tests\search_api\Kernel\Views

Code

protected function assertCacheMaxAge($expected_max_age, array $render_array) {
  $actual_max_age = CacheableMetadata::createFromRenderArray($render_array)
    ->getCacheMaxAge();
  $this
    ->assertEquals($expected_max_age, $actual_max_age);
}