PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf PHP Method

assertContainsOnlyInstancesOf() public static method

Asserts that a haystack contains only instances of a given classname
public static assertContainsOnlyInstancesOf ( string $classname, array | Traversable $haystack, string $message = '' )
$classname string
$haystack array | Traversable
$message string
    public static function assertContainsOnlyInstancesOf($classname, $haystack, $message = '')
    {
        if (!(is_array($haystack) || is_object($haystack) && $haystack instanceof Traversable)) {
            throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array or traversable');
        }
        static::assertThat($haystack, new PHPUnit_Framework_Constraint_TraversableContainsOnly($classname, false), $message);
    }

Usage Example

Example #1
0
 public function containsOnlyInstancesOf($class)
 {
     a::assertContainsOnlyInstancesOf($class, $this->actual, $this->description);
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf
PHPUnit_Framework_Assert