1010trait VerifyArrayTrait
1111{
1212 /**
13- * Asserts that a haystack contains a needle.
13+ * Verifies that a haystack contains a needle.
1414 *
1515 * @param $needle
1616 */
@@ -23,13 +23,22 @@ public function contains($needle)
2323 throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
2424 }
2525
26+ public function containsEquals ($ needle )
27+ {
28+ if (is_iterable ($ this ->actual )) {
29+ TestCase::assertContainsEquals ($ needle , $ this ->actual , $ this ->message );
30+ return ;
31+ }
32+ throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
33+ }
34+
2635 /**
27- * Asserts that a haystack contains only values of a given type.
36+ * Verifies that a haystack contains only values of a given type.
2837 *
2938 * @param string $type
3039 * @param bool|null $isNativeType
3140 */
32- public function containsOnly ($ type , $ isNativeType = null )
41+ public function containsOnly (string $ type , $ isNativeType = null )
3342 {
3443 if (is_iterable ($ this ->actual )) {
3544 TestCase::assertContainsOnly ($ type , $ this ->actual , $ isNativeType , $ this ->message );
@@ -39,11 +48,11 @@ public function containsOnly($type, $isNativeType = null)
3948 }
4049
4150 /**
42- * Asserts that a haystack contains only instances of a given class name.
51+ * Verifies that a haystack contains only instances of a given class name.
4352 *
4453 * @param string $className
4554 */
46- public function containsOnlyInstancesOf ($ className )
55+ public function containsOnlyInstancesOf (string $ className )
4756 {
4857 if (is_iterable ($ this ->actual )) {
4958 TestCase::assertContainsOnlyInstancesOf ($ className , $ this ->actual , $ this ->message );
@@ -53,11 +62,11 @@ public function containsOnlyInstancesOf($className)
5362 }
5463
5564 /**
56- * Asserts the number of elements of an array, Countable or Traversable.
65+ * Verifies the number of elements of an array, Countable or Traversable.
5766 *
5867 * @param int $expectedCount
5968 */
60- public function count ($ expectedCount )
69+ public function count (int $ expectedCount )
6170 {
6271 if (is_iterable ($ this ->actual ) || $ this ->actual instanceof Countable) {
6372 TestCase::assertCount ($ expectedCount , $ this ->actual , $ this ->message );
@@ -67,7 +76,7 @@ public function count($expectedCount)
6776 }
6877
6978 /**
70- * Asserts that an array has a specified key.
79+ * Verifies that an array has a specified key.
7180 *
7281 * @param int|string $key
7382 */
@@ -81,7 +90,7 @@ public function hasKey($key)
8190 }
8291
8392 /**
84- * Asserts that an array does not have a specified key.
93+ * Verifies that an array does not have a specified key.
8594 *
8695 * @param int|string $key
8796 */
@@ -94,9 +103,8 @@ public function hasNotKey($key)
94103 throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
95104 }
96105
97-
98106 /**
99- * Asserts that a haystack does not contain a needle.
107+ * Verifies that a haystack does not contain a needle.
100108 *
101109 * @param $needle
102110 */
@@ -109,13 +117,22 @@ public function notContains($needle)
109117 throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
110118 }
111119
120+ public function notContainsEquals ($ needle )
121+ {
122+ if (is_iterable ($ this ->actual )) {
123+ TestCase::assertNotContainsEquals ($ needle , $ this ->actual , $ this ->message );
124+ return ;
125+ }
126+ throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
127+ }
128+
112129 /**
113- * Asserts that a haystack does not contain only values of a given type.
130+ * Verifies that a haystack does not contain only values of a given type.
114131 *
115132 * @param string $type
116133 * @param bool|null $isNativeType
117134 */
118- public function notContainsOnly ($ type , $ isNativeType = null )
135+ public function notContainsOnly (string $ type , $ isNativeType = null )
119136 {
120137 if (is_iterable ($ this ->actual )) {
121138 TestCase::assertNotContainsOnly ($ type , $ this ->actual , $ isNativeType , $ this ->message );
@@ -125,11 +142,11 @@ public function notContainsOnly($type, $isNativeType = null)
125142 }
126143
127144 /**
128- * Asserts the number of elements of an array, Countable or Traversable.
145+ * Verifies the number of elements of an array, Countable or Traversable.
129146 *
130147 * @param int $expectedCount
131148 */
132- public function notCount ($ expectedCount )
149+ public function notCount (int $ expectedCount )
133150 {
134151 if (is_iterable ($ this ->actual ) || $ this ->actual instanceof Countable) {
135152 TestCase::assertNotCount ($ expectedCount , $ this ->actual , $ this ->message );
@@ -138,4 +155,31 @@ public function notCount($expectedCount)
138155 throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
139156 }
140157
158+ /**
159+ * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is not the same.
160+ *
161+ * @param Countable|iterable $expected
162+ */
163+ public function notSameSize ($ expected )
164+ {
165+ if (is_iterable ($ this ->actual ) || $ this ->actual instanceof Countable) {
166+ TestCase::assertNotSameSize ($ expected , $ this ->actual , $ this ->message );
167+ return ;
168+ }
169+ throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
170+ }
171+
172+ /**
173+ * Verifies that the size of two arrays (or `Countable` or `Traversable` objects) is the same.
174+ *
175+ * @param Countable|iterable $expected
176+ */
177+ public function sameSize ($ expected )
178+ {
179+ if (is_iterable ($ this ->actual ) || $ this ->actual instanceof Countable) {
180+ TestCase::assertSameSize ($ expected , $ this ->actual , $ this ->message );
181+ return ;
182+ }
183+ throw new InvalidVerifyException (__FUNCTION__ , $ this ->actual );
184+ }
141185}
0 commit comments