Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5d5e04b

Browse filesBrowse files
minor #32907 [PhpUnitBridge] add more assert*() polyfills (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] add more assert*() polyfills | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32844 | License | MIT | Doc PR | - Commits ------- 54ddfd2 [PhpUnitBridge] add more assert*() polyfills
2 parents d01ec68 + 54ddfd2 commit 5d5e04b
Copy full SHA for 5d5e04b

File tree

Expand file treeCollapse file tree

1 file changed

+65
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+65
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php
+65Lines 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, $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+
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.