function VariationCacheTest::getSortedCacheId

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php \Drupal\Tests\Core\Cache\VariationCacheTest::getSortedCacheId()

Creates the sorted cache ID from cache ID parts.

When core optimizes cache contexts it returns the keys alphabetically. To make testing easier, we replicate said sorting here.

Parameters

string[] $cache_id_parts: The parts to add to the base cache ID, will be sorted.

Return value

string The correct cache ID.

3 calls to VariationCacheTest::getSortedCacheId()
VariationCacheTest::testNestedVariations in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests a cache item that has nested variations.
VariationCacheTest::testNestedVariationsSelfHealing in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests a cache item that has nested variations that trigger self-healing.
VariationCacheTest::testSplitVariationsSelfHealing in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests self-healing for a cache item that has split variations.

File

core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php, line 437

Class

VariationCacheTest
@coversDefaultClass \Drupal\Core\Cache\VariationCache @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

protected function getSortedCacheId($cache_id_parts) {
    sort($cache_id_parts);
    array_unshift($cache_id_parts, $this->cacheIdBase);
    return implode(':', $cache_id_parts);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.