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/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::recursiveKSort()

Recursively sorts an array by key.

Parameters

array $array: An array to sort.

Return value

array The sorted array.

4 calls to ResourceTestBase::recursiveKSort()
EntityResourceTestBase::testGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a GET request for an entity, plus edge cases to ensure good DX.
FileUploadResourceTestBase::assertResponseData in core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php
Asserts expected normalized data matches response data.
MediaResourceTestBase::uploadFile in core/modules/media/tests/src/Functional/Rest/MediaResourceTestBase.php
This duplicates some of the 'file_upload' REST resource plugin test coverage, to be able to test it on a concrete use case.
TermResourceTestBase::testGetTermWithParent in core/modules/taxonomy/tests/src/Functional/Rest/TermResourceTestBase.php
Tests GETting a term with a parent term other than the default <root> (0).

File

core/modules/rest/tests/src/Functional/ResourceTestBase.php, line 494

Class

ResourceTestBase
Subclass this for every REST resource, every format and every auth provider.

Namespace

Drupal\Tests\rest\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);
    }
  }
}