|
11 | 11 |
|
12 | 12 | namespace Symfony\Bridge\PhpUnit\Legacy;
|
13 | 13 |
|
| 14 | +use PHPUnit\Framework\Constraint\IsEqual; |
| 15 | +use PHPUnit\Framework\Constraint\LogicalNot; |
14 | 16 | use PHPUnit\Framework\Constraint\StringContains;
|
| 17 | +use PHPUnit\Framework\Constraint\TraversableContains; |
15 | 18 | use PHPUnit\Framework\MockObject\MockObject;
|
16 | 19 | use PHPUnit\Framework\TestCase;
|
17 | 20 |
|
@@ -112,6 +115,42 @@ protected function createPartialMock($originalClassName, array $methods)
|
112 | 115 | return $mock->getMock();
|
113 | 116 | }
|
114 | 117 |
|
| 118 | + /** |
| 119 | + * @param float $delta |
| 120 | + * @param string $message |
| 121 | + * |
| 122 | + * @return void |
| 123 | + */ |
| 124 | + public static function assertEqualsWithDelta($expected, $actual, $delta, $message = '') |
| 125 | + { |
| 126 | + $constraint = new IsEqual($expected, $delta); |
| 127 | + static::assertThat($actual, $constraint, $message); |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * @param iterable $haystack |
| 132 | + * @param string $message |
| 133 | + * |
| 134 | + * @return void |
| 135 | + */ |
| 136 | + public static function assertContainsEquals($needle, $haystack, $message = '') |
| 137 | + { |
| 138 | + $constraint = new TraversableContains($needle, false, false); |
| 139 | + static::assertThat($haystack, $constraint, $message); |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * @param iterable $haystack |
| 144 | + * @param string $message |
| 145 | + * |
| 146 | + * @return void |
| 147 | + */ |
| 148 | + public static function assertNotContainsEquals($needle, $haystack, $message = '') |
| 149 | + { |
| 150 | + $constraint = new LogicalNot(new TraversableContains($needle, false, false)); |
| 151 | + static::assertThat($haystack, $constraint, $message); |
| 152 | + } |
| 153 | + |
115 | 154 | /**
|
116 | 155 | * @param string $message
|
117 | 156 | *
|
@@ -248,6 +287,32 @@ public static function assertStringContainsStringIgnoringCase($needle, $haystack
|
248 | 287 | static::assertThat($haystack, $constraint, $message);
|
249 | 288 | }
|
250 | 289 |
|
| 290 | + /** |
| 291 | + * @param string $needle |
| 292 | + * @param string $haystack |
| 293 | + * @param string $message |
| 294 | + * |
| 295 | + * @return void |
| 296 | + */ |
| 297 | + public static function assertStringNotContainsString($needle, $haystack, $message = '') |
| 298 | + { |
| 299 | + $constraint = new LogicalNot(new StringContains($needle, false)); |
| 300 | + static::assertThat($haystack, $constraint, $message); |
| 301 | + } |
| 302 | + |
| 303 | + /** |
| 304 | + * @param string $needle |
| 305 | + * @param string $haystack |
| 306 | + * @param string $message |
| 307 | + * |
| 308 | + * @return void |
| 309 | + */ |
| 310 | + public static function assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = '') |
| 311 | + { |
| 312 | + $constraint = new LogicalNot(new StringContains($needle, true)); |
| 313 | + static::assertThat($haystack, $constraint, $message); |
| 314 | + } |
| 315 | + |
251 | 316 | /**
|
252 | 317 | * @param string $message
|
253 | 318 | *
|
|
0 commit comments