protected static function ResourceResponseTestTrait::resetOmittedLinkKeys in JSON:API 8.2
Resets omitted link keys.
Omitted link keys are a link relation type + a random string. This string is meaningless and only serves to differentiate link objects. Given that these are random, we can't assert their value.
Parameters
array $omitted: An array of JSON:API omitted link objects.
2 calls to ResourceResponseTestTrait::resetOmittedLinkKeys()
- ResourceResponseTestTrait::mergeOmittedObjects in tests/
src/ Functional/ ResourceResponseTestTrait.php - Merges the links of two omitted objects and returns a new omitted object.
- ResourceTestBase::assertSameDocument in tests/
src/ Functional/ ResourceTestBase.php - Asserts that an expected document matches the response body.
File
- tests/
src/ Functional/ ResourceResponseTestTrait.php, line 656
Class
- ResourceResponseTestTrait
- Utility methods for handling resource responses.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function resetOmittedLinkKeys(array &$omitted) {
$help = $omitted['links']['help'];
$reindexed = [];
$links = array_diff_key($omitted['links'], array_flip([
'help',
]));
foreach (array_values($links) as $index => $link) {
$reindexed['item:' . $index] = $link;
}
$omitted['links'] = [
'help' => $help,
] + $reindexed;
}