You are here

protected static function ResourceResponseTestTrait::sortOmittedLinks in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::sortOmittedLinks()

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 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Asserts that an expected document matches the response body.

File

core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php, line 637

Class

ResourceResponseTestTrait
Utility methods for handling resource responses.

Namespace

Drupal\Tests\jsonapi\Functional

Code

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;
}