protected function ViewsCacheabilityMetadataExportTest::assertViewConfigCacheabilityMetadata in Search API 8
Checks that the given view config has the expected cacheability metadata.
Parameters
array $expected_cacheability_metadata: An array of cacheability metadata that is expected to be present on the view configuration.
\Drupal\Core\Config\Config $config: The configuration to check.
1 call to ViewsCacheabilityMetadataExportTest::assertViewConfigCacheabilityMetadata()
- ViewsCacheabilityMetadataExportTest::testViewExport in tests/
src/ Kernel/ Views/ ViewsCacheabilityMetadataExportTest.php - Tests that an exported view contains the right cacheability metadata.
File
- tests/
src/ Kernel/ Views/ ViewsCacheabilityMetadataExportTest.php, line 203
Class
- ViewsCacheabilityMetadataExportTest
- Tests that cacheability metadata is included when Views config is exported.
Namespace
Drupal\Tests\search_api\Kernel\ViewsCode
protected function assertViewConfigCacheabilityMetadata(array $expected_cacheability_metadata, Config $config) {
// Cacheability metadata is stored separately for each Views display since
// depending on how the display is configured it might have different
// caching needs. Ensure to check all displays.
foreach (self::$testViewDisplayIds as $display_id) {
$view_config_display = $config
->get("display.{$display_id}");
foreach ($expected_cacheability_metadata as $cache_key => $value) {
if (is_array($value)) {
$this
->assertArrayEquals($value, $view_config_display['cache_metadata'][$cache_key]);
}
else {
$this
->assertEquals($value, $view_config_display['cache_metadata'][$cache_key]);
}
}
}
}