function ResourceTestBase::recursiveKSort

Same name in this branch
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::recursiveKsort()
Same name in other branches
  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()
  3. 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::recursiveKsort()
  4. 10 core/modules/rest/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\rest\Functional\ResourceTestBase::recursiveKSort()
  5. 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::recursiveKsort()
  6. 11.x 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.

5 calls to ResourceTestBase::recursiveKSort()
EntityResourceTestBase::testGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Test a GET request for an entity, plus edge cases to ensure good DX.
FileHalJsonAnonTest::testGetBcUriField in core/modules/file/tests/src/Functional/Hal/FileHalJsonAnonTest.php
@group legacy @expectedDeprecation Replacing the file uri with the URL is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use the provided url property instead and disable hal.settings:bc_file_uri_as_url_normalizer. Seeā€¦
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 493

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.