minor #37964 [PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait (dunglas)

This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a

Move the polyfill method introduced in #37960 in the `Assert` trait. Sorry I noticed this trait later.

Commits
-------

0426113eda [PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait
This commit is contained in:
Fabien Potencier 2020-08-27 16:50:42 +02:00
commit 831966981b
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);
}
}