public static function PHPUnit_Framework_Assert::assertContains

Asserts that a haystack contains a needle.

@since Method available since Release 2.1.0

Parameters

mixed $needle:

mixed $haystack:

string $message:

boolean $ignoreCase:

boolean $checkForObjectIdentity:

11 calls to PHPUnit_Framework_Assert::assertContains()
Framework_AssertTest::testAssertArrayContainsObject in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains
Framework_AssertTest::testAssertArrayContainsString in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains
Framework_AssertTest::testAssertContainsThrowsException in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertIteratorContainsObject in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains
Framework_AssertTest::testAssertIteratorContainsString in drupal/core/vendor/phpunit/phpunit/Tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains

... See full list

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Framework/Assert.php, line 128

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

public static function assertContains($needle, $haystack, $message = '', $ignoreCase = FALSE, $checkForObjectIdentity = TRUE) {
  if (is_array($haystack) || is_object($haystack) && $haystack instanceof Traversable) {
    $constraint = new PHPUnit_Framework_Constraint_TraversableContains($needle, $checkForObjectIdentity);
  }
  else {
    if (is_string($haystack)) {
      $constraint = new PHPUnit_Framework_Constraint_StringContains($needle, $ignoreCase);
    }
    else {
      throw PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array, iterator or string');
    }
  }
  self::assertThat($haystack, $constraint, $message);
}