|
@@ 74-95 (lines=22) @@
|
| 71 |
|
* @param bool $checkForObjectIdentity |
| 72 |
|
* @param bool $checkForNonObjectIdentity |
| 73 |
|
*/ |
| 74 |
|
public static function assertContains( |
| 75 |
|
$needle, |
| 76 |
|
$haystack, |
| 77 |
|
$message = '', |
| 78 |
|
$ignoreCase = false, |
| 79 |
|
$checkForObjectIdentity = true, |
| 80 |
|
$checkForNonObjectIdentity = false |
| 81 |
|
) { |
| 82 |
|
if (is_array($haystack) || is_object($haystack) && $haystack instanceof \Traversable) { |
| 83 |
|
$constraint = self::contains($needle, $checkForObjectIdentity, $checkForNonObjectIdentity); |
| 84 |
|
} elseif (is_string($haystack)) { |
| 85 |
|
if (!is_string($needle)) { |
| 86 |
|
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
$constraint = new \PHPUnit_Framework_Constraint_StringContains($needle, $ignoreCase); |
| 90 |
|
} else { |
| 91 |
|
throw \PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array, traversable or string'); |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
\PHPUnit_Framework_Assert::assertThat($haystack, $constraint, $message); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
/** |
| 98 |
|
* @param mixed $needle |
|
@@ 105-130 (lines=26) @@
|
| 102 |
|
* @param bool $checkForObjectIdentity |
| 103 |
|
* @param bool $checkForNonObjectIdentity |
| 104 |
|
*/ |
| 105 |
|
public static function assertNotContains( |
| 106 |
|
$needle, |
| 107 |
|
$haystack, |
| 108 |
|
$message = '', |
| 109 |
|
$ignoreCase = false, |
| 110 |
|
$checkForObjectIdentity = true, |
| 111 |
|
$checkForNonObjectIdentity = false |
| 112 |
|
) { |
| 113 |
|
if (is_array($haystack) || is_object($haystack) && $haystack instanceof \Traversable) { |
| 114 |
|
$constraint = new \PHPUnit_Framework_Constraint_Not( |
| 115 |
|
self::contains($needle, $checkForObjectIdentity, $checkForNonObjectIdentity) |
| 116 |
|
); |
| 117 |
|
} elseif (is_string($haystack)) { |
| 118 |
|
if (!is_string($needle)) { |
| 119 |
|
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string'); |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
$constraint = new \PHPUnit_Framework_Constraint_Not( |
| 123 |
|
new \PHPUnit_Framework_Constraint_StringContains($needle, $ignoreCase) |
| 124 |
|
); |
| 125 |
|
} else { |
| 126 |
|
throw \PHPUnit_Util_InvalidArgumentHelper::factory(2, 'array, traversable or string'); |
| 127 |
|
} |
| 128 |
|
|
| 129 |
|
\PHPUnit_Framework_Assert::assertThat($haystack, $constraint, $message); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
/** |
| 133 |
|
* @param mixed $value |