Does anyone know what would be the best way to test a model relationship collection? Below I am testing that new players can be added to a team through an update request for the team. What I'm wanting to test at the end of the test is that players includes all players (both former and new).
toContain must be a full array of all included values.
@jrdavidson Your $formerPlayers and $newPlayers variables are collection instances, so you could merge them to check all are attached to the team after your PATCH request:
$expectedPlayers = $formerPlayers->merge($newPlayers);
// Iterate over $expectedPlayers here and assert they're attached to team
@martinbean Maybe I'm missing something here. I'm trying to make sure that the ids of the players relationship collection match the collection of all player ids match.