protected static function ResourceResponseTestTrait::sortResourceCollection in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::sortResourceCollection()
Sorts a collection of resources or resource identifiers.
This is useful for asserting collections or resources where order cannot be known in advance.
Parameters
array $resources: The resource or resource identifier.
1 call to ResourceResponseTestTrait::sortResourceCollection()
- 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 290
Class
- ResourceResponseTestTrait
- Utility methods for handling resource responses.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected static function sortResourceCollection(array &$resources) {
usort($resources, function ($a, $b) {
return strcmp("{$a['type']}:{$a['id']}", "{$b['type']}:{$b['id']}");
});
}