You can use the contains
method for assertTrue
test like:
$this->assertTrue($eloquentCollection->contains($expected));
You can also pass a key / value pair to the contains method, which will determine if the given pair exists in the collection:
$this->assertTrue($eloquentCollection->contains('id', $expected->id));
source share