1 | <?php |
||
8 | trait ArrayAssertsTrait |
||
9 | { |
||
10 | /** |
||
11 | * Asserts the given $actual array is the same as the $expected array disregarding index order |
||
12 | * |
||
13 | * @param array $expected The expected array. |
||
14 | * @param mixed $actual The actual array. |
||
15 | * @param string|null $prefix Prefix to use with error messages. Useful for nested arrays. |
||
16 | * |
||
17 | * @return void |
||
18 | */ |
||
19 | public function assertSameArray(array $expected, $actual, $prefix = null) |
||
77 | |||
78 | /** |
||
79 | * Determines if an array is a numerically indexed array i.e. an array with numeric and sequential keys. |
||
80 | * |
||
81 | * @param array $subject The array to check if indexed. |
||
82 | * |
||
83 | * @return boolean |
||
84 | */ |
||
85 | private function isNumeric(array $subject) |
||
95 | |||
96 | /** |
||
97 | * Asserts the number of elements of an array, Countable or Traversable. |
||
98 | * |
||
99 | * Ensures this method must be provided by classes using this trait. |
||
100 | * |
||
101 | * @param integer $expectedCount The expected number of items in $haystack. |
||
102 | * @param mixed $haystack The array, countable or traversable object containing items. |
||
103 | * @param string $message Optional error message to give upon failure. |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | abstract public function assertCount($expectedCount, $haystack, $message = ''); |
||
108 | |||
109 | /** |
||
110 | * Asserts that a variable is of a given type. |
||
111 | * |
||
112 | * Ensures this method must be provided by classes using this trait. |
||
113 | * |
||
114 | * @param string $expected The expected internal type. |
||
115 | * @param mixed $actual The variable to verify. |
||
116 | * @param string $message Optional error message to give upon failure. |
||
117 | * |
||
118 | * @return void |
||
119 | */ |
||
120 | abstract public function assertInternalType($expected, $actual, $message = ''); |
||
121 | |||
122 | /** |
||
123 | * Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference |
||
124 | * the same object. |
||
125 | * |
||
126 | * Ensures this method must be provided by classes using this trait. |
||
127 | * |
||
128 | * @param string $expected The expected value. |
||
129 | * @param mixed $actual The actual value. |
||
130 | * @param string $message Optional error message to give upon failure. |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | abstract public function assertSame($expected, $actual, $message = ''); |
||
135 | } |
||
136 |