I'm writing some unit tests using phpunit and I now want to assert that an array contains a certain value, but the only function I can find is assertArrayHasKey(). There is no assertArrayHasValue whatsoever.
So to be clear I want something like this:
$a = [5, 8, 16];
assertArrayHasValue(8, $a);
All tips are welcome!
You can do it with function assertContains()
try this:
$a = [5, 8, 16];
$this->assertContains(8, $a);
ASSERT_CONTAINS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With