function ResourceResponseTestTrait::sortResourceCollection
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::sortResourceCollection()
- 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceResponseTestTrait.php \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait::sortResourceCollection()
- 11.x 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 292
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']}");
});
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.