[PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait
This commit is contained in:
parent
7da56f31ba
commit
0426113eda
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user