Closed innocenzi closed 5 months ago
This pull request adds the toBeArrayOf expectation, which asserts a specific value is an array of the specified type.
toBeArrayOf
expect(User::all())->toBeArrayOf(User::class);
I very often have to deal with arrays of data objects and I copy-paste this expectation in a lot of projects:
expect(FlightData::collectFromFl3xxFlights($response)) ->toBeArrayOf(FlightData::class) ->toHaveCount(8);
I'm also thinking of either adding toBeCollectionOf, or supporting collections in toBeArrayOf. What do you think?
toBeCollectionOf
I would be open for that as well.
Thanks for your work on this!
This pull request adds the
toBeArrayOf
expectation, which asserts a specific value is an array of the specified type.I very often have to deal with arrays of data objects and I copy-paste this expectation in a lot of projects:
I'm also thinking of either adding
toBeCollectionOf
, or supporting collections intoBeArrayOf
. What do you think?