8000 minor #37964 [PhpUnitBridge] Move assertMatchesRegularExpression in P… · symfony/symfony@8319669 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8319669

Browse files
committed
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 ------- 0426113 [PhpUnitBridge] Move assertMatchesRegularExpression in PolyfillAssertTrait
2 parents 7da56f3 + 0426113 commit 8319669

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/PolyfillAssertTrait.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\Constraint\IsEqual;
1515
use PHPUnit\Framework\Constraint\LogicalNot;
16+
use PHPUnit\Framework\Constraint\RegularExpression;
1617
use PHPUnit\Framework\Constraint\StringContains;
1718
use PHPUnit\Framework\Constraint\TraversableContains;
1819

@@ -443,4 +444,24 @@ public static function assertFileNotIsWritable($filename, $message = '')
443444
static::assertFileExists($filename, $message);
444445
static::assertNotIsWritable($filename, $message);
445446
}
447+
448+
/**
449+
* Asserts that a string matches a given regular expression.
450+
*
451+
* @param string $pattern
452+
* @param string $string
453+
* @param string $message
454+
*
455+
* @return void
456+
*/
457+
public function assertMatchesRegularExpression($pattern, $string, $message = '')
458+
{
459+
static::assertThat(
460+
$string,
461+
new LogicalNot(
462+
new RegularExpression($pattern)
463+
),
464+
$message
465+
);
466+
}
446467
}

src/Symfony/Bridge/PhpUnit/Legacy/PolyfillTestCaseTrait.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\Legacy;
1313

14-
use PHPUnit\Framework\ExpectationFailedException;
1514
use PHPUnit\Framework\MockObject\MockObject;
1615
use PHPUnit\Framework\TestCase;
17-
use SebastianBergmann\RecursionContext\InvalidArgumentException;
1816

1917
/**
2018
* This trait is @internal.
@@ -118,18 +116,4 @@ public function expectExceptionMessageRegExp($messageRegExp)
118116
$property->setAccessible(true);
119117
$property->setValue($this, $messageRegExp);
120118
}
121-
122-
/**
123-
* Asserts that a string matches a given regular expression.
124-
*
125-
* @param string $pattern
126-
* @param string $string
127-
* @param string $message
128-
*
129-
* @return void
130-
*/
131-
public function assertMatchesRegularExpression($pattern, $string, $message = '')
132-
{
133-
$this->assertRegExp($pattern, $string, $message);
134-
}
135119
}

0 commit comments

Comments
 (0)
0