You are here

public static function PHPUnit_Framework_Assert::assertContains in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Framework/Assert.php \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:

bool $ignoreCase:

bool $checkForObjectIdentity:

bool $checkForNonObjectIdentity:

17 calls to PHPUnit_Framework_Assert::assertContains()
Framework_AssertTest::testAssertArrayContainsNonObject in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains
Framework_AssertTest::testAssertArrayContainsObject in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains
Framework_AssertTest::testAssertArrayContainsString in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains
Framework_AssertTest::testAssertContainsThrowsException in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains @expectedException PHPUnit_Framework_Exception
Framework_AssertTest::testAssertIteratorContainsObject in vendor/phpunit/phpunit/tests/Framework/AssertTest.php
@covers PHPUnit_Framework_Assert::assertContains

... See full list

File

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

Class

PHPUnit_Framework_Assert
A set of assert methods.

Code

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