public function UserTest::testCollectionContainsAnonymousUser in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/src/Functional/UserTest.php \Drupal\Tests\jsonapi\Functional\UserTest::testCollectionContainsAnonymousUser()
Tests that the collection contains the anonymous user.
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ UserTest.php, line 439
Class
- UserTest
- JSON:API integration test for the "User" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testCollectionContainsAnonymousUser() {
$url = Url::fromRoute('jsonapi.user--user.collection', [], [
'query' => [
'sort' => 'drupal_internal__uid',
],
]);
$request_options = [];
$request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
$request_options = NestedArray::mergeDeep($request_options, $this
->getAuthenticationRequestOptions());
$response = $this
->request('GET', $url, $request_options);
$doc = Json::decode((string) $response
->getBody());
$this
->assertCount(4, $doc['data']);
$this
->assertSame(User::load(0)
->uuid(), $doc['data'][0]['id']);
$this
->assertSame('User 0', $doc['data'][0]['attributes']['display_name']);
}