protected static function ResourceResponseTestTrait::sortOmittedLinks in JSON:API 8.2
Sorts an omitted link object array by href.
Parameters
array $omitted: An array of JSON:API omitted link objects.
1 call to ResourceResponseTestTrait::sortOmittedLinks()
- ResourceTestBase::assertSameDocument in tests/
src/ Functional/ ResourceTestBase.php - Asserts that an expected document matches the response body.
File
- tests/
src/ Functional/ ResourceResponseTestTrait.php, line 637
Class
- ResourceResponseTestTrait
- Utility methods for handling resource responses.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function sortOmittedLinks(array &$omitted) {
$help = $omitted['links']['help'];
$links = array_diff_key($omitted['links'], array_flip([
'help',
]));
uasort($links, function ($a, $b) {
return strcmp($a['href'], $b['href']);
});
$omitted['links'] = [
'help' => $help,
] + $links;
}