| @@ 268-290 (lines=23) @@ | ||
| 265 | * |
|
| 266 | * @since Method available since Release 3.1.4 |
|
| 267 | */ |
|
| 268 | public static function assertContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
|
| 269 | { |
|
| 270 | if (!(is_array($haystack) || |
|
| 271 | is_object($haystack) && $haystack instanceof Traversable)) { |
|
| 272 | throw PHPUnit_Util_InvalidArgumentHelper::factory( |
|
| 273 | 2, |
|
| 274 | 'array or traversable' |
|
| 275 | ); |
|
| 276 | } |
|
| 277 | ||
| 278 | if ($isNativeType == null) { |
|
| 279 | $isNativeType = PHPUnit_Util_Type::isType($type); |
|
| 280 | } |
|
| 281 | ||
| 282 | self::assertThat( |
|
| 283 | $haystack, |
|
| 284 | new PHPUnit_Framework_Constraint_TraversableContainsOnly( |
|
| 285 | $type, |
|
| 286 | $isNativeType |
|
| 287 | ), |
|
| 288 | $message |
|
| 289 | ); |
|
| 290 | } |
|
| 291 | ||
| 292 | /** |
|
| 293 | * Asserts that a haystack contains only instances of a given classname |
|
| @@ 351-375 (lines=25) @@ | ||
| 348 | * |
|
| 349 | * @since Method available since Release 3.1.4 |
|
| 350 | */ |
|
| 351 | public static function assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = '') |
|
| 352 | { |
|
| 353 | if (!(is_array($haystack) || |
|
| 354 | is_object($haystack) && $haystack instanceof Traversable)) { |
|
| 355 | throw PHPUnit_Util_InvalidArgumentHelper::factory( |
|
| 356 | 2, |
|
| 357 | 'array or traversable' |
|
| 358 | ); |
|
| 359 | } |
|
| 360 | ||
| 361 | if ($isNativeType == null) { |
|
| 362 | $isNativeType = PHPUnit_Util_Type::isType($type); |
|
| 363 | } |
|
| 364 | ||
| 365 | self::assertThat( |
|
| 366 | $haystack, |
|
| 367 | new PHPUnit_Framework_Constraint_Not( |
|
| 368 | new PHPUnit_Framework_Constraint_TraversableContainsOnly( |
|
| 369 | $type, |
|
| 370 | $isNativeType |
|
| 371 | ) |
|
| 372 | ), |
|
| 373 | $message |
|
| 374 | ); |
|
| 375 | } |
|
| 376 | ||
| 377 | /** |
|
| 378 | * Asserts that a haystack that is stored in a static attribute of a class |
|