bug #37960 [PhpUnit] Add polyfill for assertMatchesRegularExpression() (dunglas)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[PhpUnit] Add polyfill for assertMatchesRegularExpression()

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | yes
| Deprecations? | no
| Tickets       | n/a
| License       | MIT
| Doc PR        | n/a

`assertRegExp()` is now deprecated in favor of `assertMatchesRegularExpression`.

Commits
-------

33eccd2a00 [PhpUnit] Add polyfill for assertMatchesRegularExpression()
This commit is contained in:
Fabien Potencier 2020-08-27 16:03:12 +02:00
commit 7da56f31ba

View File

@ -11,8 +11,10 @@
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.
@ -116,4 +118,18 @@ 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);
}
}