1 | <?php |
||||||
2 | |||||||
3 | namespace Sfneal\Testing\Utils\Traits; |
||||||
4 | |||||||
5 | trait AssertArrayValues |
||||||
6 | { |
||||||
7 | // todo: add tests |
||||||
8 | |||||||
9 | /** |
||||||
10 | * Assert that an array has a value. |
||||||
11 | * |
||||||
12 | * @param $needle |
||||||
13 | * @param array $haystack |
||||||
14 | */ |
||||||
15 | public function assertArrayHasValue($needle, array $haystack) |
||||||
16 | { |
||||||
17 | $this->assertTrue( |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
18 | in_array($needle, array_values($haystack)), |
||||||
19 | "Could not find '{$needle}' in the array ".json_encode($haystack)); |
||||||
20 | } |
||||||
21 | |||||||
22 | /** |
||||||
23 | * Assert that an array does not have a value. |
||||||
24 | * |
||||||
25 | * @param $needle |
||||||
26 | * @param array $haystack |
||||||
27 | */ |
||||||
28 | public function assertArrayNotHasValue($needle, array $haystack) |
||||||
29 | { |
||||||
30 | $this->assertFalse( |
||||||
0 ignored issues
–
show
It seems like
assertFalse() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
31 | in_array($needle, array_values($haystack)), |
||||||
32 | "Could not find '{$needle}' in the array ".json_encode($haystack)); |
||||||
33 | } |
||||||
34 | } |
||||||
35 |