PHPUnit_Framework_Assert::assertSameSize PHP Method

assertSameSize() public static method

Assert that the size of two arrays (or Countable or Traversable objects) is the same.
public static assertSameSize ( array | Countable | Traversable $expected, array | Countable | Traversable $actual, string $message = '' )
$expected array | Countable | Traversable
$actual array | Countable | Traversable
$message string
    public static function assertSameSize($expected, $actual, $message = '')
    {
        if (!$expected instanceof Countable && !$expected instanceof Traversable && !is_array($expected)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'countable or traversable');
        }
        if (!$actual instanceof Countable && !$actual instanceof Traversable && !is_array($actual)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'countable or traversable');
        }
        static::assertThat($actual, new PHPUnit_Framework_Constraint_SameSize($expected), $message);
    }

Usage Example

Esempio n. 1
14
/**
 * Assert that the size of two arrays (or `Countable` or `Iterator` objects)
 * is the same.
 *
 * @param integer $expected
 * @param mixed   $actual
 * @param string  $message
 */
function assertSameSize($expected, $actual, $message = '')
{
    return PHPUnit_Framework_Assert::assertSameSize($expected, $actual, $message);
}
All Usage Examples Of PHPUnit_Framework_Assert::assertSameSize
PHPUnit_Framework_Assert