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
-------
54ddfd2ef0
[PhpUnitBridge] add more assert*() polyfills
This commit is contained in:
commit
5d5e04bea9
@ -11,7 +11,10 @@
|
||||
|
||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||
|
||||
use PHPUnit\Framework\Constraint\IsEqual;
|
||||
use PHPUnit\Framework\Constraint\LogicalNot;
|
||||
use PHPUnit\Framework\Constraint\StringContains;
|
||||
use PHPUnit\Framework\Constraint\TraversableContains;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -112,6 +115,42 @@ trait ForwardCompatTestTraitForV5
|
||||
return $mock->getMock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $delta
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertEqualsWithDelta($expected, $actual, $delta, $message = '')
|
||||
{
|
||||
$constraint = new IsEqual($expected, $delta);
|
||||
static::assertThat($actual, $constraint, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable $haystack
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertContainsEquals($needle, $haystack, $message = '')
|
||||
{
|
||||
$constraint = new TraversableContains($needle, false, false);
|
||||
static::assertThat($haystack, $constraint, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable $haystack
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertNotContainsEquals($needle, $haystack, $message = '')
|
||||
{
|
||||
$constraint = new LogicalNot(new TraversableContains($needle, false, false));
|
||||
static::assertThat($haystack, $constraint, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*
|
||||
@ -248,6 +287,32 @@ trait ForwardCompatTestTraitForV5
|
||||
static::assertThat($haystack, $constraint, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $needle
|
||||
* @param string $haystack
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertStringNotContainsString($needle, $haystack, $message = '')
|
||||
{
|
||||
$constraint = new LogicalNot(new StringContains($needle, false));
|
||||
static::assertThat($haystack, $constraint, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $needle
|
||||
* @param string $haystack
|
||||
* @param string $message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = '')
|
||||
{
|
||||
$constraint = new LogicalNot(new StringContains($needle, true));
|
||||
static::assertThat($haystack, $constraint, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*
|
||||
|
Reference in New Issue
Block a user