protected static function ResourceTestBase::recursiveKsort in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::recursiveKsort()
Recursively sorts an array by key.
Parameters
array $array: An array to sort.
2 calls to ResourceTestBase::recursiveKsort()
- ResourceTestBase::assertSameDocument in tests/
src/ Functional/ ResourceTestBase.php - Asserts that an expected document matches the response body.
- ResourceTestBase::testPostIndividual in tests/
src/ Functional/ ResourceTestBase.php - Tests POSTing an individual resource, plus edge cases to ensure good DX.
File
- tests/
src/ Functional/ ResourceTestBase.php, line 2392
Class
- ResourceTestBase
- Subclass this for every JSON API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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);
}
}
}