[PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait

This commit is contained in:
Kévin Dunglas 2020-08-27 16:43:53 +02:00
parent 7da56f31ba
commit 0426113eda
No known key found for this signature in database
GPG Key ID: 9D0C5D6EEB42C445
2 changed files with 21 additions and 16 deletions

View File

@ -13,6 +13,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
use PHPUnit\Framework\Constraint\IsEqual;
use PHPUnit\Framework\Constraint\LogicalNot;
use PHPUnit\Framework\Constraint\RegularExpression;
use PHPUnit\Framework\Constraint\StringContains;
use PHPUnit\Framework\Constraint\TraversableContains;
@ -443,4 +444,24 @@ trait PolyfillAssertTrait
static::assertFileExists($filename, $message);
static::assertNotIsWritable($filename, $message);
}
/**
* Asserts that a string matches a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
*
* @return void
*/
public function assertMatchesRegularExpression($pattern, $string, $message = '')
{
static::assertThat(
$string,
new LogicalNot(
new RegularExpression($pattern)
),
$message
);
}
}

View File

@ -11,10 +11,8 @@
namespace Symfony\Bridge\PhpUnit\Legacy;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
/**
* This trait is @internal.
@ -118,18 +116,4 @@ trait PolyfillTestCaseTrait
$property->setAccessible(true);
$property->setValue($this, $messageRegExp);
}
/**
* Asserts that a string matches a given regular expression.
*
* @param string $pattern
* @param string $string
* @param string $message
*
* @return void
*/
public function assertMatchesRegularExpression($pattern, $string, $message = '')
{
$this->assertRegExp($pattern, $string, $message);
}
}