You are here

public static function PHPUnit_Framework_Assert::assertCount in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Assert.php \PHPUnit_Framework_Assert::assertCount()

Asserts the number of elements of an array, Countable or Traversable.

Parameters

int $expectedCount:

mixed $haystack:

string $message:

10 calls to PHPUnit_Framework_Assert::assertCount()
Framework_AssertTest::testAssertCount in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertCount
Framework_AssertTest::testAssertCountThrowsExceptionIfElementIsNotCountable in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertCount
Framework_AssertTest::testAssertCountThrowsExceptionIfExpectedCountIsNoInteger in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertCount
Framework_AssertTest::testAssertCountTraversable in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertCount
ParserTest::testParse in vendor/sebastian/diff/tests/ParserTest.php

... See full list

File

vendor/phpunit/phpunit/src/Framework/Assert.php, line 396

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function assertCount($expectedCount, $haystack, $message = '') {
  if (!is_int($expectedCount)) {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'integer');
  }
  if (!$haystack instanceof Countable && !$haystack instanceof Traversable && !is_array($haystack)) {
    throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable or traversable');
  }
  self::assertThat($haystack, new PHPUnit_Framework_Constraint_Count($expectedCount), $message);
}