You are here

public function Framework_AssertTest::testAssertContainsOnlyInstancesOf in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/tests/Framework/AssertTest.php \Framework_AssertTest::testAssertContainsOnlyInstancesOf()

@covers PHPUnit_Framework_Assert::assertContainsOnlyInstancesOf

File

vendor/phpunit/phpunit/tests/Framework/AssertTest.php, line 115

Class

Framework_AssertTest
@since Class available since Release 2.0.0

Code

public function testAssertContainsOnlyInstancesOf() {
  $test = array(
    new Book(),
    new Book(),
  );
  $this
    ->assertContainsOnlyInstancesOf('Book', $test);
  $this
    ->assertContainsOnlyInstancesOf('stdClass', array(
    new stdClass(),
  ));
  $test2 = array(
    new Author('Test'),
  );
  try {
    $this
      ->assertContainsOnlyInstancesOf('Book', $test2);
  } catch (PHPUnit_Framework_AssertionFailedError $e) {
    return;
  }
  $this
    ->fail();
}