$this->
assertSame(201,
$response->
getStatusCode());
} /**
* Tests that collections can be filtered by an entity reference target_id.
*
* @see https://www.drupal.org/project/drupal/issues/3036593
*/
public function testFilteringEntitiesByEntityReferenceTargetId() { // Create two config entities to be the config targets of an entity
// reference. In this case, the `roles` field.
$role_llamalovers =
$this->
drupalCreateRole([], 'llamalovers', 'Llama Lovers'
);
$role_catcuddlers =
$this->
drupalCreateRole([], 'catcuddlers', 'Cat Cuddlers'
);
/** @var \Drupal\user\UserInterface[] $users */
for ($i = 0;
$i < 3;
$i++
) { // Create 3 users, one with the first role and two with the second role.
$users[$i] =
$this->
drupalCreateUser();
$users[$i]->
addRole($i === 0 ?
$role_llamalovers :
$role_catcuddlers);
$users[$i]->
save();
// For each user, create a node that is owned by that user. The node's
// `uid` field will be used to test filtering by a content entity ID.
Node::
create([