You are here

protected static function ResourceTestBase::recursiveKsort in Drupal 9

Same name in this branch
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::recursiveKsort()
  2. 9 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::recursiveKSort()
Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::recursiveKsort()

Recursively sorts an array by key.

Parameters

array $array: An array to sort.

3 calls to ResourceTestBase::recursiveKsort()
ResourceTestBase::assertSameDocument in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Asserts that an expected document matches the response body.
ResourceTestBase::testPatchIndividual in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests PATCHing an individual resource, plus edge cases to ensure good DX.
ResourceTestBase::testPostIndividual in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests POSTing an individual resource, plus edge cases to ensure good DX.

File

core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php, line 2535

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected static function recursiveKsort(array &$array) {

  // First, sort the main array.
  ksort($array);

  // Then check for child arrays.
  foreach ($array as $key => &$value) {
    if (is_array($value)) {
      static::recursiveKsort($value);
    }
  }
}