Skip to content
Snippets Groups Projects
Commit d4fc586b authored by Ide Braakman's avatar Ide Braakman Committed by Markus Kalkbrenner
Browse files

Issue #3327629: Replace custom assertCacheabillityArrays with PHPUnit's assertEqualsCanonicalizing

parent d6ffb6ec
No related branches found
No related tags found
No related merge requests found
......@@ -179,8 +179,8 @@ class DefaultFacetManagerTest extends EntityKernelTestBase {
// Make sure that query cachebillity will include facets cache tags e.g.
// view results will depends on the facet configuration.
$this->facetManager->alterQuery($query, $facet_source);
$this->assertCacheabillityArrays($expected_contexts, $query->getCacheContexts());
$this->assertCacheabillityArrays($expected_tags, $query->getCacheTags());
$this->assertEqualsCanonicalizing($expected_contexts, $query->getCacheContexts());
$this->assertEqualsCanonicalizing($expected_tags, $query->getCacheTags());
}
/**
......@@ -219,8 +219,8 @@ class DefaultFacetManagerTest extends EntityKernelTestBase {
$metadata = CacheableMetadata::createFromObject($facet);
$metadata->applyTo($build);
$this->assertEquals($expected_metadata['max-age'], $build['#cache']['max-age']);
$this->assertCacheabillityArrays($expected_metadata['contexts'], $build['#cache']['contexts']);
$this->assertCacheabillityArrays($expected_metadata['tags'], $build['#cache']['tags']);
$this->assertEqualsCanonicalizing($expected_metadata['contexts'], $build['#cache']['contexts']);
$this->assertEqualsCanonicalizing($expected_metadata['tags'], $build['#cache']['tags']);
$facet->removeProcessor('fpc_sort_processor');
// Test that un-cacheable plugin kills the cache.
......@@ -238,8 +238,8 @@ class DefaultFacetManagerTest extends EntityKernelTestBase {
$metadata->applyTo($build);
$this->assertEquals(0, $build['#cache']['max-age']);
$this->assertCacheabillityArrays($expected_metadata['contexts'], $build['#cache']['contexts']);
$this->assertCacheabillityArrays($expected_metadata['tags'], $build['#cache']['tags']);
$this->assertEqualsCanonicalizing($expected_metadata['contexts'], $build['#cache']['contexts']);
$this->assertEqualsCanonicalizing($expected_metadata['tags'], $build['#cache']['tags']);
}
/**
......@@ -294,22 +294,6 @@ class DefaultFacetManagerTest extends EntityKernelTestBase {
}
}
/**
* Assert that actual cachebillity matches expected one.
*/
public function assertCacheabillityArrays($expected, $actual, string $message = ''): void {
foreach ([&$expected, &$actual] as &$array) {
foreach ($array as &$value) {
if (is_array($value)) {
sort($value);
}
}
}
sort($expected);
sort($actual);
$this->assertEquals($expected, $actual, $message);
}
/**
* Data provider for testBuildCacheabilityMetadata().
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment