Skip to content

Commit 71e4e46

Browse files
[PhpUnitBridge] add more assert*() polyfills
1 parent d01ec68 commit 71e4e46

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\Legacy;
1313

14+
use PHPUnit\Framework\Constraint\IsEqual;
15+
use PHPUnit\Framework\Constraint\LogicalNot;
1416
use PHPUnit\Framework\Constraint\StringContains;
17+
use PHPUnit\Framework\Constraint\TraversableContains;
1518
use PHPUnit\Framework\MockObject\MockObject;
1619
use PHPUnit\Framework\TestCase;
1720

@@ -112,6 +115,42 @@ protected function createPartialMock($originalClassName, array $methods)
112115
return $mock->getMock();
113116
}
114117

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, iterable $haystack, string $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, iterable $haystack, string $message = '')
149+
{
150+
$constraint = new LogicalNot(new TraversableContains($needle, false, false));
151+
static::assertThat($haystack, $constraint, $message);
152+
}
153+
115154
/**
116155
* @param string $message
117156
*
@@ -248,6 +287,32 @@ public static function assertStringContainsStringIgnoringCase($needle, $haystack
248287
static::assertThat($haystack, $constraint, $message);
249288
}
250289

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+
251316
/**
252317
* @param string $message
253318
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy