|
@@ 407-424 (lines=18) @@
|
| 404 |
|
* @param mixed $haystack |
| 405 |
|
* @param string $message |
| 406 |
|
*/ |
| 407 |
|
public static function assertCount($expectedCount, $haystack, $message = '') |
| 408 |
|
{ |
| 409 |
|
if (!is_int($expectedCount)) { |
| 410 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
if (!$haystack instanceof Countable && |
| 414 |
|
!$haystack instanceof Traversable && |
| 415 |
|
!is_array($haystack)) { |
| 416 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable or traversable'); |
| 417 |
|
} |
| 418 |
|
|
| 419 |
|
self::assertThat( |
| 420 |
|
$haystack, |
| 421 |
|
new PHPUnit_Framework_Constraint_Count($expectedCount), |
| 422 |
|
$message |
| 423 |
|
); |
| 424 |
|
} |
| 425 |
|
|
| 426 |
|
/** |
| 427 |
|
* Asserts the number of elements of an array, Countable or Traversable |
|
@@ 453-470 (lines=18) @@
|
| 450 |
|
* @param mixed $haystack |
| 451 |
|
* @param string $message |
| 452 |
|
*/ |
| 453 |
|
public static function assertNotCount($expectedCount, $haystack, $message = '') |
| 454 |
|
{ |
| 455 |
|
if (!is_int($expectedCount)) { |
| 456 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer'); |
| 457 |
|
} |
| 458 |
|
|
| 459 |
|
if (!$haystack instanceof Countable && |
| 460 |
|
!$haystack instanceof Traversable && |
| 461 |
|
!is_array($haystack)) { |
| 462 |
|
throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable or traversable'); |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
$constraint = new PHPUnit_Framework_Constraint_Not( |
| 466 |
|
new PHPUnit_Framework_Constraint_Count($expectedCount) |
| 467 |
|
); |
| 468 |
|
|
| 469 |
|
self::assertThat($haystack, $constraint, $message); |
| 470 |
|
} |
| 471 |
|
|
| 472 |
|
/** |
| 473 |
|
* Asserts the number of elements of an array, Countable or Traversable |