| @@ 128-157 (lines=30) @@ | ||
| 125 | * |
|
| 126 | * @since Method available since Release 2.1.0 |
|
| 127 | */ |
|
| 128 | public static function assertContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
|
| 129 | { |
|
| 130 | if (is_array($haystack) || |
|
| 131 | is_object($haystack) && $haystack instanceof Traversable) { |
|
| 132 | $constraint = new PHPUnit_Framework_Constraint_TraversableContains( |
|
| 133 | $needle, |
|
| 134 | $checkForObjectIdentity, |
|
| 135 | $checkForNonObjectIdentity |
|
| 136 | ); |
|
| 137 | } elseif (is_string($haystack)) { |
|
| 138 | if (!is_string($needle)) { |
|
| 139 | throw PHPUnit_Util_InvalidArgumentHelper::factory( |
|
| 140 | 1, |
|
| 141 | 'string' |
|
| 142 | ); |
|
| 143 | } |
|
| 144 | ||
| 145 | $constraint = new PHPUnit_Framework_Constraint_StringContains( |
|
| 146 | $needle, |
|
| 147 | $ignoreCase |
|
| 148 | ); |
|
| 149 | } else { |
|
| 150 | throw PHPUnit_Util_InvalidArgumentHelper::factory( |
|
| 151 | 2, |
|
| 152 | 'array, traversable or string' |
|
| 153 | ); |
|
| 154 | } |
|
| 155 | ||
| 156 | self::assertThat($haystack, $constraint, $message); |
|
| 157 | } |
|
| 158 | ||
| 159 | /** |
|
| 160 | * Asserts that a haystack that is stored in a static attribute of a class |
|
| @@ 197-230 (lines=34) @@ | ||
| 194 | * |
|
| 195 | * @since Method available since Release 2.1.0 |
|
| 196 | */ |
|
| 197 | public static function assertNotContains($needle, $haystack, $message = '', $ignoreCase = false, $checkForObjectIdentity = true, $checkForNonObjectIdentity = false) |
|
| 198 | { |
|
| 199 | if (is_array($haystack) || |
|
| 200 | is_object($haystack) && $haystack instanceof Traversable) { |
|
| 201 | $constraint = new PHPUnit_Framework_Constraint_Not( |
|
| 202 | new PHPUnit_Framework_Constraint_TraversableContains( |
|
| 203 | $needle, |
|
| 204 | $checkForObjectIdentity, |
|
| 205 | $checkForNonObjectIdentity |
|
| 206 | ) |
|
| 207 | ); |
|
| 208 | } elseif (is_string($haystack)) { |
|
| 209 | if (!is_string($needle)) { |
|
| 210 | throw PHPUnit_Util_InvalidArgumentHelper::factory( |
|
| 211 | 1, |
|
| 212 | 'string' |
|
| 213 | ); |
|
| 214 | } |
|
| 215 | ||
| 216 | $constraint = new PHPUnit_Framework_Constraint_Not( |
|
| 217 | new PHPUnit_Framework_Constraint_StringContains( |
|
| 218 | $needle, |
|
| 219 | $ignoreCase |
|
| 220 | ) |
|
| 221 | ); |
|
| 222 | } else { |
|
| 223 | throw PHPUnit_Util_InvalidArgumentHelper::factory( |
|
| 224 | 2, |
|
| 225 | 'array, traversable or string' |
|
| 226 | ); |
|
| 227 | } |
|
| 228 | ||
| 229 | self::assertThat($haystack, $constraint, $message); |
|
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * Asserts that a haystack that is stored in a static attribute of a class |
|