// Also when looking at the collection.
$response =
$this->
request('GET',
$collection_url,
$request_options);
$doc = Json::
decode((string) $response->
getBody());
$this->
assertSame($user_a->
uuid(),
$doc['data'
]['2'
]['id'
]);
$this->
assertArrayHasKey('mail',
$doc['data'
][2
]['attributes'
]);
} /**
* Tests good error DX when trying to filter users by role.
*/
public function testQueryInvolvingRoles() { $this->
setUpAuthorization('GET'
);
$collection_url = Url::
fromRoute('jsonapi.user--user.collection',
[],
['query' =>
['filter[roles.id][value]' => 'e9b1de3f-9517-4c27-bef0-0301229de792'
]]);
$request_options =
[];
$request_options[RequestOptions::HEADERS
]['Accept'
] = 'application/vnd.api+json';
$request_options = NestedArray::
mergeDeep($request_options,
$this->
getAuthenticationRequestOptions());
// The 'administer users' permission is required to filter by role entities.
$this->
grantPermissionsToTestedRole(['administer users'
]);
$response =
$this->
request('GET',
$collection_url,
$request_options);
$expected_cache_contexts =
['url.path', 'url.query_args:filter', 'url.site'
];