Skip to content

[PhpUnitBridge] add more assert*() polyfills #32907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions src/Symfony/Bridge/PhpUnit/Legacy/ForwardCompatTestTraitForV5.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -112,6 +115,42 @@ protected function createPartialMock($originalClassName, array $methods)
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
*
Expand Down Expand Up @@ -248,6 +287,32 @@ public static function assertStringContainsStringIgnoringCase($needle, $haystack
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
*
Expand Down