From b6f73dbf1d40467c4a07c6b4fb8f86d579055f85 Mon Sep 17 00:00:00 2001 From: Guilliam Xavier Date: Fri, 31 Aug 2018 16:00:15 +0200 Subject: [PATCH] Re-add a test for #2907 (lost in commit d0dab53) --- .../Constraint/StringMatchesFormatDescriptionTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Framework/Constraint/StringMatchesFormatDescriptionTest.php b/tests/Framework/Constraint/StringMatchesFormatDescriptionTest.php index bc9fe7a6131..b13d2bbd0a9 100644 --- a/tests/Framework/Constraint/StringMatchesFormatDescriptionTest.php +++ b/tests/Framework/Constraint/StringMatchesFormatDescriptionTest.php @@ -193,6 +193,16 @@ public function testConstraintStringMatchesCharacter(): void $this->assertCount(1, $constraint); } + public function testConstraintStringMatchesEscapedPercent(): void + { + $constraint = new StringMatchesFormatDescription('%%,%%e,%%s,%%S,%%a,%%A,%%w,%%i,%%d,%%x,%%f,%%c,%%Z,%%%%,%%'); + + $this->assertFalse($constraint->evaluate('%%,%' . \DIRECTORY_SEPARATOR . ',%*,%*,%*,%*,% ,%0,%0,%0f0f0f,%1.0,%*,%%Z,%%%%,%%', '', true)); + $this->assertTrue($constraint->evaluate('%,%e,%s,%S,%a,%A,%w,%i,%d,%x,%f,%c,%Z,%%,%', '', true)); + $this->assertEquals('matches PCRE pattern "/^%,%e,%s,%S,%a,%A,%w,%i,%d,%x,%f,%c,%Z,%%,%$/s"', $constraint->toString()); + $this->assertCount(1, $constraint); + } + public function testConstraintStringMatchesSlash(): void { $constraint = new StringMatchesFormatDescription('/');