diff --git a/src/Runner/Baseline/Issue.php b/src/Runner/Baseline/Issue.php index 869ea26a4bc..4cfcb96821b 100644 --- a/src/Runner/Baseline/Issue.php +++ b/src/Runner/Baseline/Issue.php @@ -13,6 +13,7 @@ use function assert; use function file; use function is_file; +use function preg_match; use function sha1; use PHPUnit\Runner\FileDoesNotExistException; @@ -112,7 +113,7 @@ public function equals(self $other): bool return $this->file() === $other->file() && $this->line() === $other->line() && $this->hash() === $other->hash() && - $this->description() === $other->description(); + ($this->description() === $other->description() || preg_match('{' . $this->description() . '}', $other->description()) > 0); } /** diff --git a/tests/end-to-end/_files/baseline/use-baseline-with-regex/baseline.xml b/tests/end-to-end/_files/baseline/use-baseline-with-regex/baseline.xml new file mode 100644 index 00000000000..7725c5245ad --- /dev/null +++ b/tests/end-to-end/_files/baseline/use-baseline-with-regex/baseline.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/end-to-end/_files/baseline/use-baseline-with-regex/phpunit.xml b/tests/end-to-end/_files/baseline/use-baseline-with-regex/phpunit.xml new file mode 100644 index 00000000000..bf0ee15c129 --- /dev/null +++ b/tests/end-to-end/_files/baseline/use-baseline-with-regex/phpunit.xml @@ -0,0 +1,14 @@ + + + + + tests + + + + + + diff --git a/tests/end-to-end/_files/baseline/use-baseline-with-regex/tests/UseBaselineTest.php b/tests/end-to-end/_files/baseline/use-baseline-with-regex/tests/UseBaselineTest.php new file mode 100644 index 00000000000..d7baf78d8e5 --- /dev/null +++ b/tests/end-to-end/_files/baseline/use-baseline-with-regex/tests/UseBaselineTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\Baseline; + +use const E_USER_DEPRECATED; +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class UseBaselineTest extends TestCase +{ + public function testOne(): void + { + trigger_error('deprecation 123', E_USER_DEPRECATED); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/baseline/use-baseline-with-regex.phpt b/tests/end-to-end/baseline/use-baseline-with-regex.phpt new file mode 100644 index 00000000000..edb2d9680b4 --- /dev/null +++ b/tests/end-to-end/baseline/use-baseline-with-regex.phpt @@ -0,0 +1,24 @@ +--TEST-- +phpunit --configuration ../_files/baseline/use-baseline-with-regex/phpunit.xml +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s +Configuration: %s + +. 1 / 1 (100%) + +Time: %s, Memory: %s + +OK (1 test, 1 assertion) + +1 issue was ignored by baseline. diff --git a/tests/unit/Runner/Baseline/IssueTest.php b/tests/unit/Runner/Baseline/IssueTest.php index b484f3c93f4..06c46c64062 100644 --- a/tests/unit/Runner/Baseline/IssueTest.php +++ b/tests/unit/Runner/Baseline/IssueTest.php @@ -50,6 +50,11 @@ public function testIsComparable(): void $this->assertFalse($this->issue()->equals($this->anotherIssue())); } + public function testIsComparableWithRegex(): void + { + $this->assertTrue($this->issueWithRegex()->equals($this->issue())); + } + public function testCannotBeCreatedForFileThatDoesNotExist(): void { $this->expectException(FileDoesNotExistException::class); @@ -84,6 +89,16 @@ private function issue(): Issue ); } + private function issueWithRegex(): Issue + { + return Issue::from( + realpath(__DIR__ . '/../../../_files/baseline/FileWithIssues.php'), + 10, + null, + '(.)*', + ); + } + private function anotherIssue(): Issue { return Issue::from(