Feature request: Some or any array items match an expectation #1355
paulshryock
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Given some
$things
which are nested arrays:I would like a way to
expect
that "some" or "any" of the nested things contains anid
of2
.In a test, I can first drill down inside
getThings()
and pluck out thesomething.id
's before my expectation:But currently there seems to be no available expectation available to reach in without doing my own
array_map
logic outside of the expectation first.We do have
expect()->toContain()
and we do haveexpect()->toMatchArray()
, but neither quite works for this scenario of deeply nested arrays.I don't know what the ideal syntax might be, but maybe something like:
or
This is very similar to
expect()->every
, except instead of insisting that every item meets a given expectation, it would check that some or any of the items meet a given expectation.Beta Was this translation helpful? Give feedback.
All reactions