diff --git a/test/Feature/CleanRegex/PatternList/replace/callback/PatternListTest.php b/test/Feature/CleanRegex/PatternList/replace/callback/PatternListTest.php index 537d88ac5..01e186bd0 100644 --- a/test/Feature/CleanRegex/PatternList/replace/callback/PatternListTest.php +++ b/test/Feature/CleanRegex/PatternList/replace/callback/PatternListTest.php @@ -30,12 +30,10 @@ public function test(int $times, string $expected) '(\s+|\?)', ]; $pattern = Pattern::list(\array_slice($patterns, 0, $times)); - // when $replaced = $pattern ->replace("Do you think that's air you're breathing now?") ->callback(Functions::constant('__')); - // then $this->assertSame($expected, $replaced); } @@ -64,14 +62,12 @@ public function shouldInvokeCallbackForOnePattern() $replace = $pattern->replace('a 1 b 2 c 3'); $matches = []; $subjects = []; - // when $result = $replace->callback(function (Detail $detail) use (&$matches, &$subjects) { $matches[] = $detail->text(); $subjects[] = $detail->subject(); return '_'; }); - // then $first = 'a 1 b 2 c 3'; $second = '_ 1 _ 2 _ 3'; diff --git a/test/Feature/CleanRegex/_delimiter/PatternTest.php b/test/Feature/CleanRegex/_delimiter/PatternTest.php index 39c356f8a..c2bea341a 100644 --- a/test/Feature/CleanRegex/_delimiter/PatternTest.php +++ b/test/Feature/CleanRegex/_delimiter/PatternTest.php @@ -18,7 +18,6 @@ public function test(string $input) { // when $pattern = Pattern::of("\Q$input\E"); - // then $this->assertConsumesFirst($input, $pattern); } diff --git a/test/Feature/CleanRegex/_extended/_reset/PatternTest.php b/test/Feature/CleanRegex/_extended/_reset/PatternTest.php index 200ebe82b..1c72242d7 100644 --- a/test/Feature/CleanRegex/_extended/_reset/PatternTest.php +++ b/test/Feature/CleanRegex/_extended/_reset/PatternTest.php @@ -17,7 +17,6 @@ public function shouldAddComment_ResetButSetAgain() { // when $pattern = Pattern::inject("(?^x)#@\n", []); - // then $this->assertPatternIs("/(?^x)#@\n/", $pattern); } @@ -29,7 +28,6 @@ public function shouldUsePlaceholder_PatternExtended_Reset() { // when $pattern = Pattern::inject("(?^)#@\n", ['Foo'], 'x'); - // then $this->assertConsumesFirstPcre2("#Foo\n", $pattern); $this->assertPatternIs("/(?^)#(?>Foo)\n/x", $pattern); @@ -42,7 +40,6 @@ public function shouldUsePlaceholder_PatternExtended_ResetShort() { // when $pattern = Pattern::inject("(?^:#@\n)", ['Foo'], 'x'); - // then $this->assertConsumesFirstPcre2("#Foo\n", $pattern); $this->assertPatternIs("/(?^:#(?>Foo)\n)/x", $pattern); @@ -55,7 +52,6 @@ public function shouldUsePlaceholder_SubpatternExtended_Reset() { // when $pattern = Pattern::inject("(?x)(?^:#@\n)", ['Foo']); - // then $this->assertConsumesFirstPcre2("#Foo\n", $pattern); $this->assertPatternIs("/(?x)(?^:#(?>Foo)\n)/", $pattern); @@ -70,7 +66,6 @@ public function shouldAddComment_ResetButSetAgainCaseSensitiveFlag() { // when $pattern = Pattern::inject("(?^X)#@\n", ['Bar']); - // then $this->assertPatternIs("/(?^X)#(?>Bar)\n/", $pattern); } @@ -84,7 +79,6 @@ public function shouldAddComment_ResetButSetAgainExtraExtended() { // when $pattern = Pattern::inject("(?^xx)#@\n", []); - // then $this->assertPatternIs("/(?^xx)#@\n/", $pattern); } @@ -98,7 +92,6 @@ public function shouldAddComment_ResetButSetAgainCombination() { // when $pattern = Pattern::inject("(?^imx)#@\n", []); - // then $this->assertPatternIs("/(?^imx)#@\n/", $pattern); } @@ -112,7 +105,6 @@ public function shouldUsePlaceholder_SetExtendedResetOtherSubpattern() { // when $pattern = Pattern::inject("(?x:(?^))#@\n", ['Bar']); - // then $this->assertConsumesFirstPcre2("#Bar\n", $pattern); $this->assertPatternIs("/(?x:(?^))#(?>Bar)\n/", $pattern); @@ -127,7 +119,6 @@ public function shouldUsePlaceholder_SetExtendedResetSubpattern() { // when $pattern = Pattern::inject("(?ix:(?^)#@\n)", ['Bar']); - // then $this->assertConsumesFirstPcre2("#Bar\n", $pattern); $this->assertPatternIs("/(?ix:(?^)#(?>Bar)\n)/", $pattern); @@ -142,7 +133,6 @@ public function shouldAddComment_SetExtendedReset() { // when $pattern = Pattern::inject("(?x)((?^))#@\n", []); - // then $this->assertPatternIs("/(?x)((?^))#@\n/", $pattern); } @@ -156,7 +146,6 @@ public function shouldAddComment_SetExtendedResetShort() { // when $pattern = Pattern::inject("(?x)(?^:)#@\n", []); - // then $this->assertPatternIs("/(?x)(?^:)#@\n/", $pattern); } diff --git a/test/Feature/CleanRegex/_extended/_whitespace/PatternTest.php b/test/Feature/CleanRegex/_extended/_whitespace/PatternTest.php index 04229dcb7..5ac77b361 100644 --- a/test/Feature/CleanRegex/_extended/_whitespace/PatternTest.php +++ b/test/Feature/CleanRegex/_extended/_whitespace/PatternTest.php @@ -16,7 +16,6 @@ public function shouldInject() { // when $pattern = Pattern::inject("@:bar", ["user\ninput"]); - // then $this->assertConsumesFirst("user\ninput:bar", $pattern); } @@ -28,7 +27,6 @@ public function shouldInject_ExtendedMode() { // when $pattern = Pattern::inject("@:bar", ["user\n\vinput"], 'x'); - // then $this->assertConsumesFirst("user\n\vinput:bar", $pattern); } @@ -40,7 +38,6 @@ public function shouldTemplateLiteral_ExtendedMode() { // when $pattern = Pattern::template('@:bar', 'x')->literal("user\n\vinput"); - // then $this->assertConsumesFirst("user\n\vinput:bar", $pattern); } diff --git a/test/Feature/CleanRegex/_flags/PatternTest.php b/test/Feature/CleanRegex/_flags/PatternTest.php index 22ed4cac1..03bd29c4c 100644 --- a/test/Feature/CleanRegex/_flags/PatternTest.php +++ b/test/Feature/CleanRegex/_flags/PatternTest.php @@ -16,10 +16,8 @@ public function shouldBuild_inject() { // given $pattern = Pattern::inject('Foo@', ['Bar'], 'i'); - // when $flagIsAdded = $pattern->test('foobar'); - // then $this->assertTrue($flagIsAdded); } @@ -31,10 +29,8 @@ public function shouldBuild_template_literal() { // given $pattern = Pattern::template('Foo@', 'i')->literal('Bar'); - // when $flagIsAdded = $pattern->test('foobar'); - // then $this->assertTrue($flagIsAdded); } @@ -46,7 +42,6 @@ public function shouldBuild_mask() { // when $pattern = Pattern::mask('Cat:%w', ['%w' => 'Foo'], 'i'); - // then $this->assertConsumesFirst('cat:foo', $pattern); } diff --git a/test/Feature/CleanRegex/_prepared/builder/PatternTest.php b/test/Feature/CleanRegex/_prepared/builder/PatternTest.php index caf9e56c7..328a50520 100644 --- a/test/Feature/CleanRegex/_prepared/builder/PatternTest.php +++ b/test/Feature/CleanRegex/_prepared/builder/PatternTest.php @@ -24,7 +24,6 @@ public function shouldNotMistakeLiteralForPlaceholder(string $pattern, string $e { // when $pattern = Pattern::builder($pattern)->build(); - // then $this->assertPatternIs($expected, $pattern); } @@ -87,11 +86,9 @@ public function shouldThrowForSuperfluousTemplateMask() { // given $builder = Pattern::builder('Foo')->mask('foo', ['foo', 'bar']); - // then $this->expectException(PlaceholderFigureException::class); $this->expectExceptionMessage("Supplied a superfluous figure. Used 0 placeholders, but 1 figures supplied."); - // when $builder->build(); } @@ -103,11 +100,9 @@ public function shouldThrowForSuperfluousBuilderTemplateAlteration() { // given $builder = Pattern::builder('Foo')->alteration(['foo', 'bar']); - // then $this->expectException(PlaceholderFigureException::class); $this->expectExceptionMessage("Supplied a superfluous figure. Used 0 placeholders, but 1 figures supplied."); - // when $builder->build(); } @@ -133,11 +128,9 @@ public function shouldThrowForSuperfluousTemplatePattern() { // given $builder = Pattern::builder('Foo')->pattern('bar'); - // then $this->expectException(PlaceholderFigureException::class); $this->expectExceptionMessage('Supplied a superfluous figure. Used 0 placeholders, but 1 figures supplied.'); - // when $builder->build(); } @@ -149,11 +142,9 @@ public function shouldThrowForRequiredExplicitDelimiter() { // given $builder = Pattern::builder("s~i/e#++m%a!\@*`_-;=,\1"); - // then $this->expectException(ExplicitDelimiterRequiredException::class); $this->expectExceptionMessage("Failed to select a distinct delimiter to enable template in its entirety"); - // when $builder->build(); } diff --git a/test/Feature/CleanRegex/_prepared/inject/PatternTest.php b/test/Feature/CleanRegex/_prepared/inject/PatternTest.php index 5ad2b2a0d..9290b2fd3 100644 --- a/test/Feature/CleanRegex/_prepared/inject/PatternTest.php +++ b/test/Feature/CleanRegex/_prepared/inject/PatternTest.php @@ -21,7 +21,6 @@ public function shouldUsePlaceholder(string $pattern, string $expected) { // when $pattern = Pattern::inject($pattern, ['X']); - // then $this->assertPatternIs($expected, $pattern); } @@ -45,7 +44,6 @@ public function shouldNotMistakeLiteralForPlaceholder(string $pattern, string $e { // when $pattern = Pattern::inject($pattern, []); - // then $this->assertPatternIs($expected, $pattern); } @@ -69,7 +67,6 @@ public function shouldIgnorePlaceholderInGroupComment() { // when $pattern = Pattern::inject('foo(?#@', []); - // then $this->assertPatternIs('/foo(?#@/', $pattern); } @@ -81,7 +78,6 @@ public function shouldIncludeRemainderInPattern() { // when $pattern = Pattern::inject("(?x)#@\n", []); - // then $this->assertPatternIs("/(?x)#@\n/", $pattern); } @@ -94,7 +90,6 @@ public function shouldCloseRemainder() { // when $pattern = Pattern::inject("(#@\n(?x)#@\n)#@\n", ['One', 'Three']); - // then $this->assertConsumesFirst("#One\n#Three\n", $pattern); $this->assertPatternIs("/(#(?>One)\n(?x)#@\n)#(?>Three)\n/", $pattern); @@ -108,7 +103,6 @@ public function shouldCloseRemainderAndParentPattern() { // when $pattern = Pattern::inject("(?x:(?x))#@\n", ['Bar']); - // then $this->assertConsumesFirst("#Bar\n", $pattern); $this->assertPatternIs("/(?x:(?x))#(?>Bar)\n/", $pattern); @@ -122,7 +116,6 @@ public function shouldIncludeRemainderInSubpattern() { // when $pattern = Pattern::inject("(?x)(#@\n)", []); - // then $this->assertPatternIs("/(?x)(#@\n)/", $pattern); } @@ -135,7 +128,6 @@ public function shouldIncludeRemainderInNextPattern() { // when $pattern = Pattern::inject("(?x)()#@\n", []); - // then $this->assertPatternIs("/(?x)()#@\n/", $pattern); } @@ -149,7 +141,6 @@ public function shouldIncludeRemainderInNextSubpattern() { // when $pattern = Pattern::inject("(?x)()(#@\n)", []); - // then $this->assertPatternIs("/(?x)()(#@\n)/", $pattern); } @@ -162,7 +153,6 @@ public function shouldIncludeRemainderInNextSubpatternBeforeGroupNull() { // when $pattern = Pattern::inject("(?x)(?:)(#@\n)", []); - // then $this->assertPatternIs("/(?x)(?:)(#@\n)/", $pattern); } @@ -175,7 +165,6 @@ public function shouldIncludeRemainderInNextSubpatternBeforeGroupNullShort() { // when $pattern = Pattern::inject("(?x)(?)(#@\n)", []); - // then $this->assertPatternIs("/(?x)(?)(#@\n)/", $pattern); } @@ -188,7 +177,6 @@ public function shouldIncludeRemainderInNextSubpatternBeforeGroupComment() { // when $pattern = Pattern::inject("(?x)(?#)#@\n", []); - // then $this->assertPatternIs("/(?x)(?#)#@\n/", $pattern); } @@ -201,7 +189,6 @@ public function shouldCloseRemainderInNextPattern() { // when $pattern = Pattern::inject("((?x))#@\n", ['Bar']); - // then $this->assertPatternIs("/((?x))#(?>Bar)\n/", $pattern); } @@ -214,7 +201,6 @@ public function shouldCloseRemainderInNextSubpattern() { // when $pattern = Pattern::inject("((?x))(#@\n)", ['Bar']); - // then $this->assertPatternIs("/((?x))(#(?>Bar)\n)/", $pattern); } @@ -227,7 +213,6 @@ public function shouldIncludeManyRemainders() { // when $pattern = Pattern::inject("(?x)(?-x)(#@\n)", ['Bar']); - // then $this->assertPatternIs("/(?x)(?-x)(#(?>Bar)\n)/", $pattern); } @@ -240,7 +225,6 @@ public function shouldCancelManyRemainders() { // when $pattern = Pattern::inject("((?x)(?-x))#@\n", ['Bar']); - // then $this->assertPatternIs("/((?x)(?-x))#(?>Bar)\n/", $pattern); } diff --git a/test/Feature/CleanRegex/_prepared/template/PatternTest.php b/test/Feature/CleanRegex/_prepared/template/PatternTest.php index 7e38b36cf..abe9d5fda 100644 --- a/test/Feature/CleanRegex/_prepared/template/PatternTest.php +++ b/test/Feature/CleanRegex/_prepared/template/PatternTest.php @@ -24,7 +24,6 @@ public function shouldUsePlaceholder(string $pattern, string $expected) { // when $pattern = Pattern::template($pattern)->literal('X'); - // then $this->assertPatternIs($expected, $pattern); } @@ -73,7 +72,6 @@ public function shouldBuildTemplateWithPattern() { // when $pattern = Pattern::template('foo:@')->pattern('#https?/www%'); - // then $this->assertPatternIs('~foo:(?:#https?/www%)~', $pattern); $this->assertConsumesFirst('foo:#http/www%', $pattern); @@ -86,7 +84,6 @@ public function shouldMatchDelimiterPattern() { // when $pattern = Pattern::template('@')->pattern('/'); - // then $this->assertPatternIs('#(?:/)#', $pattern); $this->assertConsumesFirst('/', $pattern); @@ -100,7 +97,6 @@ public function shouldThrowForEmptyKeyword() // then $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Keyword cannot be empty, must consist of at least one character'); - // when Pattern::template('@')->mask('foo', ['' => 'Bar']); } @@ -112,7 +108,6 @@ public function shouldTemplatePatternAcceptTrailingControlBackslash() { // when $pattern = Pattern::template('/foo:@')->pattern('\c\\'); - // then $this->assertConsumesFirst('/foo:' . \chr(28), $pattern); $this->assertPatternIs('#/foo:(?:\c\)#', $pattern); @@ -125,10 +120,8 @@ public function shouldInjectAcceptTrailingCommentBackslash() { // given $pattern = Pattern::inject('#\\', []); - // when $valid = $pattern->valid(); - // then $this->assertFalse($valid); } @@ -140,7 +133,6 @@ public function shouldMaskAcceptTrailingSlashInControlCharacter() { // when $pattern = Pattern::template('@')->mask('!s', ['!s' => '\c\\']); - // then $this->assertConsumesFirst(\chr(28), $pattern); } @@ -152,7 +144,6 @@ public function shouldMaskAcceptTrailingSlashInQuote() { // when $pattern = Pattern::template('@')->mask('!s', ['!s' => '\\\\']); - // then $this->assertConsumesFirst('\\', $pattern); } @@ -176,7 +167,6 @@ public function shouldTemplateMaskThrowForRequiredExplicitDelimiterSingleKeyword // then $this->expectException(ExplicitDelimiterRequiredException::class); $this->expectExceptionMessage("Failed to select a distinct delimiter to enable mask pattern 's~i/e#++m%a!@*`_-;=,\1' assigned to keyword '@'"); - // when Pattern::template('@')->mask('@', ['@' => "s~i/e#++m%a!@*`_-;=,\1"]); } @@ -189,7 +179,6 @@ public function shouldTemplateMaskThrowPreferentiallyTrailingBackslashInsteadOfE // then $this->expectException(MaskMalformedPatternException::class); $this->expectExceptionMessage("Malformed pattern 's~i/e#++m%a!@*`_-;=,\1\' assigned to keyword 's'"); - // when Pattern::template('@')->mask('s', ['s' => "s~i/e#++m%a!@*`_-;=,\1\\"]); } @@ -202,7 +191,6 @@ public function shouldTemplateMaskThrowForRequiredExplicitDelimiterMultipleKeywo // then $this->expectException(ExplicitDelimiterRequiredException::class); $this->expectExceptionMessage("Failed to select a distinct delimiter to enable template in its entirety"); - // when Pattern::template('@')->mask(' ', ['@' => "s~i/e#++", '&' => "m%a!@*`_-;=,\1"]); } diff --git a/test/Feature/CleanRegex/_trailing_backslash/PatternTest.php b/test/Feature/CleanRegex/_trailing_backslash/PatternTest.php index 4b6687a14..9ffebe322 100644 --- a/test/Feature/CleanRegex/_trailing_backslash/PatternTest.php +++ b/test/Feature/CleanRegex/_trailing_backslash/PatternTest.php @@ -21,7 +21,6 @@ public function shouldThrow_forTrailingBackslash(Pattern $pattern): void // then $this->expectException(PatternMalformedPatternException::class); $this->expectExceptionMessage('Pattern may not end with a trailing backslash'); - // when $pattern->test('Foo'); } @@ -45,7 +44,6 @@ public function shouldThrow_forTrailingBackslash_list(): void // then $this->expectException(PatternMalformedPatternException::class); $this->expectExceptionMessage('Pattern may not end with a trailing backslash'); - // when Pattern::list(['Foo & \\'])->testAny('Foo'); } @@ -61,7 +59,6 @@ public function shouldThrow_template_forTrailingBackslash(callable $entryPoint, // then $this->expectException(MaskMalformedPatternException::class); $this->expectExceptionMessage($message); - // when $entryPoint(); } @@ -91,7 +88,6 @@ public function shouldAcceptEscapedTrailingBashslash() { // when $pattern = Pattern::of('foo\\\\'); - // then $this->assertConsumesFirst('foo\\', $pattern); } diff --git a/test/Feature/CleanRegex/match/Detail/group/isInt/DetailTest.php b/test/Feature/CleanRegex/match/Detail/group/isInt/DetailTest.php index fce661a3c..f2ad5396a 100644 --- a/test/Feature/CleanRegex/match/Detail/group/isInt/DetailTest.php +++ b/test/Feature/CleanRegex/match/Detail/group/isInt/DetailTest.php @@ -71,7 +71,6 @@ public function shouldBeInt_byName() ->forEach(function (Detail $detail) { // when $isInt = $detail->group('value')->isInt(); - // then $this->assertTrue($isInt); }); @@ -88,7 +87,6 @@ public function shouldBeInt_byIndex() ->map(function (Detail $detail) { // when $isInt = $detail->group(1)->isInt(); - // then $this->assertTrue($isInt); }); diff --git a/test/Feature/CleanRegex/match/Detail/group/toInt/DetailTest.php b/test/Feature/CleanRegex/match/Detail/group/toInt/DetailTest.php index c7ad8a702..0a53d269a 100644 --- a/test/Feature/CleanRegex/match/Detail/group/toInt/DetailTest.php +++ b/test/Feature/CleanRegex/match/Detail/group/toInt/DetailTest.php @@ -94,7 +94,6 @@ public function shouldParseInt_byName() // when return $detail->group('value')->toInt(); }); - // then $this->assertSame([12, 14, 13, 19, 18, 2], $result); } @@ -111,7 +110,6 @@ public function shouldParseInt_byIndex() // when return $detail->group(1)->toInt(); }); - // then $this->assertSame([12, 14, 13, 19, 18, 2], $result); } diff --git a/test/Feature/CleanRegex/replace/withGroup/Test.php b/test/Feature/CleanRegex/replace/withGroup/Test.php index 9770af515..e0396bb96 100644 --- a/test/Feature/CleanRegex/replace/withGroup/Test.php +++ b/test/Feature/CleanRegex/replace/withGroup/Test.php @@ -277,12 +277,10 @@ public function shouldThrow_groupNotMatch_lastGroup_thirdIndex_breaking() // given $pattern = Pattern::of('(?Foo)(?Bar)?(?;)'); $replace = $pattern->replace('FooBar; FooBar; Foo; Foo;'); - try { $replace->withGroup('bar'); } catch (GroupNotMatchedException $ignored) { } - // then $this->expectException(GroupNotMatchedException::class); $this->expectExceptionMessage("Expected to replace with group 'bar', but the group was not matched"); diff --git a/test/Feature/CleanRegex/stream/reduce/StreamTest.php b/test/Feature/CleanRegex/stream/reduce/StreamTest.php index 1f4764d74..208c87ddc 100644 --- a/test/Feature/CleanRegex/stream/reduce/StreamTest.php +++ b/test/Feature/CleanRegex/stream/reduce/StreamTest.php @@ -68,7 +68,6 @@ public function shouldReduce_throwForTooManyArguments() $tooManyArguments = function ($one, $two, $three) { $this->fail(); }; - // then $this->expectException(\ArgumentCountError::class); // when @@ -84,7 +83,6 @@ public function shouldReduce_throwForInvalidArgument() $tooManyArguments = function ($one, int $invalid) { $this->fail(); }; - // then $this->expectException(\TypeError::class); // when diff --git a/test/Functional/PcreTest.php b/test/Functional/PcreTest.php index 3aebb1941..f7016c669 100644 --- a/test/Functional/PcreTest.php +++ b/test/Functional/PcreTest.php @@ -21,7 +21,6 @@ public function shouldObeyContract() $version = Pcre::semanticVersion(); $major = Pcre::majorVersion(); $minor = Pcre::minorVersion(); - // then $this->assertSame($version, "$major.$minor"); } @@ -33,7 +32,6 @@ public function shouldGetPcreVersion() { // when $version = Pcre::semanticVersion(); - // then $this->assertStringStartsWith($version, \PCRE_VERSION); } @@ -55,17 +53,14 @@ public function shouldNotBeProneToConstantOverride() if (\PHP_VERSION_ID >= 70300) { $this->markTestUnnecessary("PHP with PCRE2 is not prone to constant override"); } - // given \define('PCRE_VERSION_MAJOR', 1200); \define('PCRE_VERSION_MINOR', 1300); - // when $semantic = Pcre::semanticVersion(); $minor = Pcre::minorVersion(); $major = Pcre::majorVersion(); $pcre2 = Pcre::pcre2(); - // then $this->assertLessThan(1100, $major); $this->assertLessThan(1100, $minor); diff --git a/test/Functional/SafeRegex/Internal/Guard/GuardedExecutionTest.php b/test/Functional/SafeRegex/Internal/Guard/GuardedExecutionTest.php index 0ff8cca51..a381f947d 100644 --- a/test/Functional/SafeRegex/Internal/Guard/GuardedExecutionTest.php +++ b/test/Functional/SafeRegex/Internal/Guard/GuardedExecutionTest.php @@ -22,7 +22,6 @@ public function shouldCatchRuntimeWarningWhenInvoking() // then $this->expectException(RuntimePregException::class); $this->expectExceptionMessage('After invoking preg_match(), preg_last_error() returned PREG_BAD_UTF8_ERROR'); - // when GuardedExecution::invoke('preg_match', '', function () { $this->causeRuntimeWarning(); @@ -38,7 +37,6 @@ public function shouldCatchCompileWarningWhenInvoking() // then $this->expectException(MalformedPatternException::class); $this->expectExceptionMessage("No ending delimiter '/' found"); - // when GuardedExecution::invoke('preg_match', '', function () { $this->causeMalformedPatternWarning(); @@ -54,7 +52,6 @@ public function shouldRethrowException() // then $this->expectException(Exception::class); $this->expectExceptionMessage('Rethrown exception'); - // when GuardedExecution::invoke('preg_match', '', Functions::throws(new Exception('Rethrown exception'))); } @@ -66,7 +63,6 @@ public function shouldInvokeReturnResult() { // when $result = GuardedExecution::invoke('preg_match', '', Functions::constant(13)); - // then $this->assertSame(13, $result); } diff --git a/test/Functional/SafeRegex/_bug77827/pregTest.php b/test/Functional/SafeRegex/_bug77827/pregTest.php index 80ed8fbc3..73c68312a 100644 --- a/test/Functional/SafeRegex/_bug77827/pregTest.php +++ b/test/Functional/SafeRegex/_bug77827/pregTest.php @@ -13,7 +13,6 @@ public function testMatch(string $flag) { // when preg::match("~foo~$flag", 'foo', $match); - // then $this->assertSame(['foo'], $match); } @@ -25,7 +24,6 @@ public function testMatchAll(string $flag) { // when preg::match_all("~foo~$flag", 'foo', $match); - // then $this->assertSame([['foo']], $match); } @@ -37,7 +35,6 @@ public function testReplace(string $flag) { // when $result = preg::replace("~foo~$flag", 'bar', 'foo'); - // then $this->assertSame('bar', $result); } @@ -49,7 +46,6 @@ public function testFilter(string $flag) { // when $result = preg::filter("~foo~$flag", 'bar', 'foo'); - // then $this->assertSame('bar', $result); } @@ -61,7 +57,6 @@ public function testFilterArray(string $flag) { // when $result = preg::filter(["~foo~$flag"], 'bar', 'foo'); - // then $this->assertSame('bar', $result); } @@ -73,7 +68,6 @@ public function testReplaceCallback(string $flag) { // when $result = preg::replace_callback("~foo~$flag", 'json_encode', 'foo'); - // then $this->assertSame('["foo"]', $result); } @@ -85,7 +79,6 @@ public function testReplaceCallbackArray(string $flag) { // when $result = preg::replace_callback_array(["~foo~$flag" => 'json_encode'], 'foo'); - // then $this->assertSame('["foo"]', $result); } @@ -97,7 +90,6 @@ public function testSplit(string $flag) { // when $parts = preg::split("~[,.]~$flag", 'a.b,c'); - // then $this->assertSame(['a', 'b', 'c'], $parts); } @@ -109,7 +101,6 @@ public function testGrep(string $flag) { // when $parts = preg::grep("~f.o~$flag", ['foo', 'bar', 'fao', 'bao']); - // then $this->assertSame(['foo', 2 => 'fao'], $parts); } diff --git a/test/Functional/SafeRegex/_callback_flags/pregTest.php b/test/Functional/SafeRegex/_callback_flags/pregTest.php index 2db44a9ce..e9d537052 100644 --- a/test/Functional/SafeRegex/_callback_flags/pregTest.php +++ b/test/Functional/SafeRegex/_callback_flags/pregTest.php @@ -18,13 +18,10 @@ public function shouldPassFlagToPregReplaceCallback() if (\PHP_VERSION_ID < 70400) { $this->markTestUnnecessary("PHP with PCRE2 is not prone to constant override"); } - // given $collected = null; - // when preg::replace_callback('/Foo/', DetailFunctions::out($collected), 'Foo', -1, $count, \PREG_OFFSET_CAPTURE); - // then $this->assertSame([['Foo', 0]], $collected); } @@ -36,10 +33,8 @@ public function shouldCallPregReplaceCallbackWithoutFlags() { // given $collected = null; - // when preg::replace_callback('/Foo/', DetailFunctions::out($collected), 'Foo', -1, $count, 0); - // then $this->assertSame(['Foo'], $collected); } diff --git a/test/Functional/SafeRegex/_fatalErrors/pregTest.php b/test/Functional/SafeRegex/_fatalErrors/pregTest.php index 96a99983b..6f4d37ed8 100644 --- a/test/Functional/SafeRegex/_fatalErrors/pregTest.php +++ b/test/Functional/SafeRegex/_fatalErrors/pregTest.php @@ -18,7 +18,6 @@ public function shouldNotThrowFatalErrors_forAnyPhpType_grep($input) { // when preg::grep('/./', [$input]); - // then $this->assertTrue(true); } @@ -32,7 +31,6 @@ public function shouldNotThrowFatalErrors_forAnyPhpType_replace_callback($input) { // when preg::replace_callback('/./', Functions::constant($input), 'word'); - // then $this->assertTrue(true); } @@ -47,7 +45,6 @@ public function shouldNotThrowFatalErrors_butThrowException_replace_callback($in // then $this->expectException(InvalidReturnValueException::class); $this->expectExceptionMessage('Invalid preg_replace_callback() callback return type. Expected type that can be cast to string, but object given'); - // when preg::replace_callback('/./', Functions::constant($input), 'word'); } @@ -64,7 +61,6 @@ public function shouldNotThrowFatalErrors_forAnyPhpType_replace_callback_array($ '/./' => Functions::constant($input), '/a/' => Functions::constant($input), ], 'word'); - // then $this->assertTrue(true); } @@ -89,7 +85,6 @@ public function shouldNotThrowFatalErrors_butThrowException_replace_callback_arr // then $this->expectException(InvalidReturnValueException::class); $this->expectExceptionMessage('Invalid preg_replace_callback_array() callback return type. Expected type that can be cast to string, but object given'); - // when preg::replace_callback_array([ '/./' => Functions::constant('a'), @@ -105,7 +100,6 @@ public function shouldThrow_forInvalidCallback_preg_replace_callback_array() // given $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid callback passed to preg_replace_callback_array()'); - // when preg::replace_callback_array(['/a/' => 4], 'word'); } diff --git a/test/Functional/SafeRegex/_offsets/pregTest.php b/test/Functional/SafeRegex/_offsets/pregTest.php index a240333ab..b4de1a0c9 100644 --- a/test/Functional/SafeRegex/_offsets/pregTest.php +++ b/test/Functional/SafeRegex/_offsets/pregTest.php @@ -18,7 +18,6 @@ public function shouldMatch_throwForInvalidOffset(string $subject, int $offset, // then $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage($message); - // when preg::match('/Foo/', $subject, $matches, 0, $offset); } @@ -30,10 +29,8 @@ public function shouldMatch_countBytes(): void { // given $twoBytesPerLetter = 'łąęśćź'; - // when preg::match_all('/.+/', $twoBytesPerLetter, $match, 0, 8); - // then $this->assertSame('ćź', $match[0][0]); } @@ -50,7 +47,6 @@ public function shouldMatchAll_throwForInvalidOffset(string $subject, int $offse // then $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage($message); - // when preg::match_all('/Foo/', $subject, $matches, 0, $offset); } @@ -62,10 +58,8 @@ public function shouldMatchAll_countBytes(): void { // given $twoBytesPerLetter = 'łąęśćź'; - // when preg::match_all('/.+/', $twoBytesPerLetter, $match, 0, 8); - // then $this->assertSame('ćź', $match[0][0]); } diff --git a/test/Functional/SafeRegex/grep_keys/pregTest.php b/test/Functional/SafeRegex/grep_keys/pregTest.php index cf6488a1a..5f4c12c8e 100644 --- a/test/Functional/SafeRegex/grep_keys/pregTest.php +++ b/test/Functional/SafeRegex/grep_keys/pregTest.php @@ -20,10 +20,8 @@ public function shouldGrepKeys() 'b' => new \stdClass(), '11' => true, ]; - // when $result = preg::grep_keys('/\d+/', $input); - // then $this->assertSame(['9' => ['Foo', 'Bar'], '10' => true, '11' => true], $result); } @@ -42,10 +40,8 @@ public function shouldGrepKeys_inverted() 'b' => $object, '11' => true ]; - // when $result = preg::grep_keys('/\d+/', $input, PREG_GREP_INVERT); - // then $this->assertSame(['a' => false, 'b' => $object], $result); } @@ -57,7 +53,6 @@ public function shouldGetEmptyArray_emptyInput_preg_grep_keys() { // when $result = preg::grep_keys('//', []); - // then $this->assertEmpty($result); } @@ -70,7 +65,6 @@ public function shouldThrow_forInvalidPattern() // then $this->expectException(MalformedPatternException::class); $this->expectExceptionMessage("Quantifier does not follow a repeatable item at offset 0"); - // when preg::grep_keys('/+/', []); } diff --git a/test/Functional/SafeRegex/pregTest.php b/test/Functional/SafeRegex/pregTest.php index 948fc2fc4..43309c079 100644 --- a/test/Functional/SafeRegex/pregTest.php +++ b/test/Functional/SafeRegex/pregTest.php @@ -24,7 +24,6 @@ public function shouldGetEmptyArray_emptyInput_preg_replace() { // when $result = preg::replace([], [], []); - // then $this->assertEmpty($result); } @@ -36,7 +35,6 @@ public function shouldGetEmptyArray_emptyInput_preg_filter() { // when $result = preg::filter([], [], []); - // then $this->assertEmpty($result); } @@ -48,7 +46,6 @@ public function shouldGetEmptyArray_arrayInput_filteredOut() { // when $result = preg::filter('/c/', '', ['a', 'b']); - // then $this->assertEmpty($result); } @@ -61,7 +58,6 @@ public function shouldBeProneToRegexCallbackWarnings() // then $this->expectException(MalformedPatternException::class); $this->expectExceptionMessage("No ending delimiter '/' found"); - // when preg::replace_callback('/valid/', function () { $this->causeMalformedPatternWarning(); @@ -79,7 +75,6 @@ public function shouldBeIndependentOfCallbackWarning() trigger_error('some other warning', E_USER_WARNING); return 'maybe'; }, 'valid'); - // then $this->assertTrue(true); } @@ -106,7 +101,6 @@ public function shouldPregMatchReturn1_onAllPhpVersions() { // when $value = preg::match('/^|\d{1,2}$/', "7"); - // then $this->assertSame(1, $value); } @@ -118,12 +112,10 @@ public function shouldGetLastErrorMessage() { // given $this->causeRuntimeWarning(); - // when $error = preg::last_error(); $message = preg::last_error_msg(); $constant = preg::last_error_constant(); - // then $this->assertSame(PREG_BAD_UTF8_ERROR, $error); $this->assertSame('Malformed UTF-8 characters, possibly incorrectly encoded', $message); @@ -137,7 +129,6 @@ public function shouldQuoteHash() { // when $quoted = preg::quote('Hello # there'); - // then $this->assertSame('Hello \# there', $quoted); } @@ -149,7 +140,6 @@ public function shouldQuoteHashWithDelimiter() { // when $quoted = preg::quote('Hello # % there', '%'); - // then $this->assertSame('Hello \# \% there', $quoted); } @@ -161,7 +151,6 @@ public function shouldQuoteHashWithHashDelimiter() { // when $quoted = preg::quote('Hello # % there', '#'); - // then $this->assertSame('Hello \# % there', $quoted); } @@ -173,7 +162,6 @@ public function shouldUnquote() { // when $unquoted = preg::unquote('\[a\-z\]\+'); - // then $this->assertSame('[a-z]+', $unquoted); } @@ -187,7 +175,6 @@ public function shouldPreserveContract(string $input) { // when $output = preg::unquote(preg::quote($input)); - // then $this->assertSame($input, $output); } @@ -211,10 +198,8 @@ public function shouldNotUnquote_regularCharacters() { // given $input = '\\\' \" \/ \;'; - // when $unquoted = preg::unquote($input); - // then $this->assertSame($input, $unquoted); } @@ -228,7 +213,6 @@ public function shouldReplaceWithStringObject() $result = preg::replace_callback('/valid/', function () { return new ClassWithToString("replaced"); }, 'valid'); - // then $this->assertSame("replaced", $result); } @@ -241,7 +225,6 @@ public function shouldQuoteThrow_forInvalidDelimiter_long() // then $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Delimiter must be one alpha-numeric character'); - // when preg::quote('Hello # % there', '##'); } @@ -254,7 +237,6 @@ public function shouldQuoteThrow_forInvalidDelimiter_empty() // then $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Delimiter must be one alpha-numeric character'); - // when preg::quote('Hello # % there', ''); } @@ -269,7 +251,6 @@ public function shouldThrowRuntimeException_withPregPattern() '/./' => Functions::constant('a'), '/a(/' => Functions::constant('b'), ]; - // when try { preg::replace_callback_array($patterns, 'word'); @@ -287,7 +268,6 @@ public function shouldThrowForInvalidUtf8Offset(): void // given $this->expectException(UnicodeOffsetException::class); $this->expectExceptionMessage('Invalid UTF-8 offset parameter was passed to preg_match()'); - // when preg::match('/€/u', '€', $match, 0, 1); } @@ -302,7 +282,6 @@ public function shouldThrowInvalidReturnValueException_withPregPattern() '/./' => Functions::constant('a'), '/a/' => Functions::constant(new \stdClass()), ]; - // when try { preg::replace_callback_array($patterns, 'word'); diff --git a/test/Legacy/CleanRegex/Internal/Match/Stream/Base/StreamBaseTest.php b/test/Legacy/CleanRegex/Internal/Match/Stream/Base/StreamBaseTest.php index de4671c41..f10e669e4 100644 --- a/test/Legacy/CleanRegex/Internal/Match/Stream/Base/StreamBaseTest.php +++ b/test/Legacy/CleanRegex/Internal/Match/Stream/Base/StreamBaseTest.php @@ -22,10 +22,8 @@ public function shouldGetAll() { // given $stream = new StreamBase(new ConstantAllBase($this->matchesOffset())); - // when $all = $stream->all(); - // then $this->assertSame(['Joffrey', 'Cersei', 'Ilyn Payne', 'The Hound'], $all->getTexts()); } @@ -37,10 +35,8 @@ public function shouldReturn_first() { // given $stream = new StreamBase(new ConstantFirstBase($this->matchOffset())); - // when $first = $stream->first(); - // then $this->assertSame('Joffrey', $first->getText()); } @@ -52,10 +48,8 @@ public function shouldThrow_first_forUnmatched() { // given $stream = new StreamBase(new ConstantFirstBase(new RawMatchOffset([]))); - // then $this->expectException(UnmatchedStreamException::class); - // when $stream->first(); } @@ -67,10 +61,8 @@ public function shouldAll_returnEmpty_unmatched() { // given $stream = new StreamBase(new ConstantAllBase(new RawMatchesOffset([[]]))); - // then $this->expectException(UnmatchedStreamException::class); - // when $stream->all(); } diff --git a/test/Legacy/CleanRegex/Internal/Model/GroupPolyfillDecoratorTest.php b/test/Legacy/CleanRegex/Internal/Model/GroupPolyfillDecoratorTest.php index a8c4161b6..9170b275e 100644 --- a/test/Legacy/CleanRegex/Internal/Model/GroupPolyfillDecoratorTest.php +++ b/test/Legacy/CleanRegex/Internal/Model/GroupPolyfillDecoratorTest.php @@ -25,7 +25,6 @@ public function test_hasGroup_true() { // given $decorator = new GroupPolyfillDecorator($this->match(['group' => 'value']), new ThrowFactory(), -10); - // when, then $this->assertTrue($decorator->hasGroup(new GroupName('group'))); } @@ -37,7 +36,6 @@ public function test_hasGroup_call() { // given $decorator = new GroupPolyfillDecorator(new ThrowFalseNegative(), new ConstantAll(['group' => null]), -10); - // when, then $this->assertTrue($decorator->hasGroup(new GroupName('group'))); } @@ -49,7 +47,6 @@ public function test_hasGroup_false() { // given $decorator = new GroupPolyfillDecorator(new ThrowFalseNegative(), new ConstantAll([]), -10); - // when, then $this->assertFalse($decorator->hasGroup(new GroupName('group'))); } @@ -61,7 +58,6 @@ public function test_isGroupMatched_true() { // given $decorator = new GroupPolyfillDecorator($this->match(['group' => ['value', 0]]), new ThrowFactory(), -10); - // when, then $this->assertTrue($decorator->isGroupMatched('group')); } @@ -88,7 +84,6 @@ public function test_isGroupMatched_call_explicitlyNotMatched() // given $decorator = new GroupPolyfillDecorator($this->match(['group' => ['value', -1]]), new ThrowFactory(), -10); - // when, then $this->assertFalse($decorator->isGroupMatched('group')); } @@ -100,7 +95,6 @@ public function test_isGroupMatched_false() { // given $decorator = new GroupPolyfillDecorator(new ThrowFalseNegative(), new ConstantAll(['group' => [[null, -1]]]), 0); - // when, then $this->assertFalse($decorator->isGroupMatched('group')); } @@ -112,7 +106,6 @@ public function test_getGroupTextAndOffset() { // given $decorator = new GroupPolyfillDecorator($this->match(['group' => ['Foo', 2]]), new ThrowFactory(), -10); - // when, then $this->assertSame(['Foo', 2], $decorator->getGroupTextAndOffset('group')); } @@ -124,7 +117,6 @@ public function test_getGroupTextAndOffset_call() { // given $decorator = new GroupPolyfillDecorator(new ThrowFalseNegative(), new ConstantAll(['group' => [['Foo', 2]]]), 0); - // when, then $this->assertSame(['Foo', 2], $decorator->getGroupTextAndOffset('group')); } @@ -140,7 +132,6 @@ public function test_getGroupTextAndOffset_call_explicitlyNotMatched() // given $decorator = new GroupPolyfillDecorator($this->match(['group' => ['value', -1]]), new ThrowFactory(), -10); - // when, then $this->assertSame(['value', -1], $decorator->getGroupTextAndOffset('group')); } @@ -152,7 +143,6 @@ public function test_getText() { // given $decorator = new GroupPolyfillDecorator($this->match([0 => ['value', -10]]), new ThrowFactory(), -10); - // when, then $this->assertSame('value', $decorator->text()); } @@ -164,7 +154,6 @@ public function test_getByteOffset() { // given $decorator = new GroupPolyfillDecorator($this->match([0 => ['value', 15]]), new ThrowFactory(), -10); - // when, then $this->assertSame(15, $decorator->byteOffset()); } diff --git a/test/Legacy/CleanRegex/Internal/Model/Match/LightweightGroupAwareTest.php b/test/Legacy/CleanRegex/Internal/Model/Match/LightweightGroupAwareTest.php index b69f2bb97..1e842cf9f 100644 --- a/test/Legacy/CleanRegex/Internal/Model/Match/LightweightGroupAwareTest.php +++ b/test/Legacy/CleanRegex/Internal/Model/Match/LightweightGroupAwareTest.php @@ -19,10 +19,8 @@ public function shouldGetGroupKeys() { // given $groupAware = new LightweightGroupAware(new Definition('/(?)/')); - // when $keys = $groupAware->getGroupKeys(); - // then $this->assertSame([0, 'group', 1], $keys); } @@ -37,10 +35,8 @@ public function shouldVerify(string $pattern, bool $expected) { // given $groupAware = new LightweightGroupAware(new Definition($pattern)); - // when $hasGroup = $groupAware->hasGroup(new GroupName('group')); - // then $this->assertSame($expected, $hasGroup); } diff --git a/test/Legacy/CleanRegex/Internal/Numeral/PositiveNotationTest.php b/test/Legacy/CleanRegex/Internal/Numeral/PositiveNotationTest.php index 66236caf2..fe374034c 100644 --- a/test/Legacy/CleanRegex/Internal/Numeral/PositiveNotationTest.php +++ b/test/Legacy/CleanRegex/Internal/Numeral/PositiveNotationTest.php @@ -25,10 +25,8 @@ public function shouldParse(string $input, int $expected, int $base) { // given $number = new PositiveNotation($input); - // when $integer = $number->integer(new Base($base)); - // then $this->assertSame($expected, $integer); } @@ -112,10 +110,8 @@ public function shouldThrowForOverflow(string $value, int $base) { // given $number = new PositiveNotation($value); - // then $this->expectException(NumeralOverflowException::class); - // when $number->integer(new Base($base)); } @@ -158,10 +154,8 @@ public function shouldThrowForMalformedValues(string $value, int $base) { // given $number = new PositiveNotation($value); - // then $this->expectException(NumeralFormatException::class); - // when $number->integer(new Base($base)); } @@ -182,10 +176,8 @@ public function shouldThrowForUnacceptedCharacters(string $value, int $_, int $b { // given $number = new PositiveNotation($value); - // then $this->expectException(NumeralFormatException::class); - // when $number->integer(new Base($base - 1)); } @@ -198,10 +190,8 @@ public function shouldBaseAcceptTheCornerDigit(string $value, int $expected, int { // given $number = new PositiveNotation($value); - // when $integer = $number->integer(new Base($base)); - // then $this->assertSame($expected, $integer); } @@ -253,10 +243,8 @@ public function shouldNotTrimRightZeros() { // given $number = new PositiveNotation('10'); - // when $integer = $number->integer(new Base(10)); - // then $this->assertSame(10, $integer); } diff --git a/test/Legacy/CleanRegex/Internal/Numeral/StringNumeralTest.php b/test/Legacy/CleanRegex/Internal/Numeral/StringNumeralTest.php index a38a1f953..61e0121fa 100644 --- a/test/Legacy/CleanRegex/Internal/Numeral/StringNumeralTest.php +++ b/test/Legacy/CleanRegex/Internal/Numeral/StringNumeralTest.php @@ -26,10 +26,8 @@ public function shouldParse(string $input, $expected, int $base) { // given $numeral = new StringNumeral($input); - // when $integer = $numeral->asInt(new Base($base)); - // then $this->assertSame($expected, $integer); } @@ -227,10 +225,8 @@ public function shouldThrowForOverflow(string $value, int $base) { // given $number = new StringNumeral($value); - // then $this->expectException(NumeralOverflowException::class); - // when $number->asInt(new Base($base)); } @@ -417,10 +413,8 @@ public function shouldThrowForMalformedValues(int $base, string $value) { // given $number = new StringNumeral($value); - // then $this->expectException(NumeralFormatException::class); - // when $number->asInt(new Base($base)); } @@ -438,10 +432,8 @@ public function shouldThrowForCornerDigit(int $base, string $value) { // given $number = new StringNumeral($value); - // then $this->expectException(NumeralFormatException::class); - // when $number->asInt(new Base($base)); } @@ -458,10 +450,8 @@ public function testZero() { // given $number = new StringNumeral('000'); - // when $format = $number->asInt(new Base(12)); - // then $this->assertSame(0, $format); } @@ -473,10 +463,8 @@ public function shouldThrowMalformedForEmpty() { // given $number = new StringNumeral(''); - // then $this->expectException(NumeralFormatException::class); - // when $number->asInt(new ThrowBase()); } @@ -488,10 +476,8 @@ public function shouldParseCaseInsensitively() { // given $number = new StringNumeral('-ABC'); - // when $integer = $number->asInt(new Base(13)); - // then $this->assertSame(-1845, $integer); } @@ -504,10 +490,8 @@ public function shouldBeCaseInsensitiveForBounds(string $number, int $expected) { // given $number = new StringNumeral($number); - // when $integer = $number->asInt(new Base(36)); - // then $this->assertSame($expected, $integer); } diff --git a/test/Legacy/SafeRegex/Exception/CompilePregExceptionTest.php b/test/Legacy/SafeRegex/Exception/CompilePregExceptionTest.php index 2e2b2999b..9e53d1f20 100644 --- a/test/Legacy/SafeRegex/Exception/CompilePregExceptionTest.php +++ b/test/Legacy/SafeRegex/Exception/CompilePregExceptionTest.php @@ -15,12 +15,10 @@ public function testGetters() { // given $exception = new CompilePregException('', '', '', new PhpError(2, 'message'), 'error'); - // when $error = $exception->getError(); $errorName = $exception->getErrorName(); $errorMessage = $exception->getPregErrorMessage(); - // then $this->assertSame(2, $error); $this->assertSame('error', $errorName); @@ -34,10 +32,8 @@ public function shouldGet_invokingMessage() { // given $exception = new CompilePregException('preg_method', null, '', new PhpError(2, ''), ''); - // when $method = $exception->getInvokingMethod(); - // then $this->assertSame('preg_method', $method); } @@ -49,10 +45,8 @@ public function shouldGet_pattern() { // given $exception = new CompilePregException('', '/pattern/', '', new PhpError(2, ''), ''); - // when $pattern = $exception->getPregPattern(); - // then $this->assertSame('/pattern/', $pattern); } diff --git a/test/Legacy/SafeRegex/Exception/SuspectedReturnPregExceptionTest.php b/test/Legacy/SafeRegex/Exception/SuspectedReturnPregExceptionTest.php index 8611007c0..ca18353a4 100644 --- a/test/Legacy/SafeRegex/Exception/SuspectedReturnPregExceptionTest.php +++ b/test/Legacy/SafeRegex/Exception/SuspectedReturnPregExceptionTest.php @@ -14,12 +14,10 @@ public function testGetters() { // given $exception = new SuspectedReturnPregException('method', '/pattern/', true); - // when $method = $exception->getInvokingMethod(); $pattern = $exception->getPregPattern(); $value = $exception->getReturnValue(); - // then $this->assertSame('method', $method); $this->assertSame('/pattern/', $pattern); @@ -30,10 +28,8 @@ public function shouldAcceptPatternsAsArray() { // given $exception = new SuspectedReturnPregException('', ['/foo/', '/bar/'], null); - // when $pattern = $exception->getPregPattern(); - // then $this->assertSame(['/foo/', '/bar/'], $pattern); } diff --git a/test/Legacy/SafeRegex/Internal/BugTest.php b/test/Legacy/SafeRegex/Internal/BugTest.php index 869bceddb..0ab671443 100644 --- a/test/Legacy/SafeRegex/Internal/BugTest.php +++ b/test/Legacy/SafeRegex/Internal/BugTest.php @@ -17,7 +17,6 @@ public function shouldFixString() { // when $result = Bug::fix("foo\r\t\f\v"); - // then $this->assertSame('foo', $result); } @@ -29,7 +28,6 @@ public function shouldFixArray() { // when $result = Bug::fix(["foo\r\t\f\v", "bar\r\t\f\v"]); - // then $this->assertSame(['foo', 'bar'], $result); } @@ -41,7 +39,6 @@ public function shouldIgnoreOtherTypes() { // when $result = Bug::fix(12); - // then $this->assertSame(12, $result); } diff --git a/test/Legacy/SafeRegex/Internal/Factory/RuntimePregExceptionFactoryTest.php b/test/Legacy/SafeRegex/Internal/Factory/RuntimePregExceptionFactoryTest.php index cdd00af1f..36ac7853d 100644 --- a/test/Legacy/SafeRegex/Internal/Factory/RuntimePregExceptionFactoryTest.php +++ b/test/Legacy/SafeRegex/Internal/Factory/RuntimePregExceptionFactoryTest.php @@ -28,10 +28,8 @@ public function shouldCreateException(int $errorCode, string $name, string $clas { // given $factory = new RuntimePregExceptionFactory('preg_method', '/pattern/', $errorCode); - // when $exception = $factory->create(); - // then $this->assertInstanceOf($className, $exception); $this->assertSame('preg_method', $exception->getInvokingMethod()); diff --git a/test/Legacy/SafeRegex/Internal/Guard/GuardedInvokerTest.php b/test/Legacy/SafeRegex/Internal/Guard/GuardedInvokerTest.php index 8390ac5f2..3eb14fdc8 100644 --- a/test/Legacy/SafeRegex/Internal/Guard/GuardedInvokerTest.php +++ b/test/Legacy/SafeRegex/Internal/Guard/GuardedInvokerTest.php @@ -44,10 +44,8 @@ public function shouldCatchRuntimeWarning() $this->causeRuntimeWarning(); return 14; }, new DefaultSuspectedReturnStrategy()); - // when [$result, $exception] = $invoker->catch(); - // then $this->assertSame(14, $result); $this->assertInstanceOf(RuntimePregException::class, $exception); @@ -64,10 +62,8 @@ public function shouldCatchMalformedWarning() $this->causeMalformedPatternWarning(); return 15; }, new DefaultSuspectedReturnStrategy()); - // when [$result, $exception] = $invoker->catch(); - // then $this->assertSame(15, $result); $this->assertInstanceOf(MalformedPatternException::class, $exception); @@ -81,10 +77,8 @@ public function shouldReturnResult() { // given $invoker = new GuardedInvoker('preg_match', '/p/', Functions::constant(16), new DefaultSuspectedReturnStrategy()); - // when [$result, $exception] = $invoker->catch(); - // then $this->assertSame(16, $result); $this->assertNull($exception); @@ -149,11 +143,9 @@ public function shouldNotSilenceExceptions() { // given $invoker = new GuardedInvoker('preg_match', '/p/', Functions::throws(new \Exception("For Frodo")), new DefaultSuspectedReturnStrategy()); - // then $this->expectException(\Exception::class); $this->expectExceptionMessage("For Frodo"); - // when $invoker->catch(); } diff --git a/test/Legacy/SafeRegex/Internal/Guard/Strategy/DefaultSuspectedReturnStrategyTest.php b/test/Legacy/SafeRegex/Internal/Guard/Strategy/DefaultSuspectedReturnStrategyTest.php index b5d121903..8a36beac9 100644 --- a/test/Legacy/SafeRegex/Internal/Guard/Strategy/DefaultSuspectedReturnStrategyTest.php +++ b/test/Legacy/SafeRegex/Internal/Guard/Strategy/DefaultSuspectedReturnStrategyTest.php @@ -22,10 +22,8 @@ public function shouldNotBeSuspected(string $methodName, $result) { // given $failureIndicators = new DefaultSuspectedReturnStrategy(); - // when $isSuspected = $failureIndicators->isSuspected($methodName, $result); - // then $this->assertFalse($isSuspected); } @@ -52,10 +50,8 @@ public function shouldBeSuspected(string $methodName, $result) { // given $failureIndicators = new DefaultSuspectedReturnStrategy(); - // when $isSuspected = $failureIndicators->isSuspected($methodName, $result); - // then $this->assertTrue($isSuspected); } diff --git a/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregFilterSuspectedReturnStrategyTest.php b/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregFilterSuspectedReturnStrategyTest.php index 8a359d45f..27590fa48 100644 --- a/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregFilterSuspectedReturnStrategyTest.php +++ b/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregFilterSuspectedReturnStrategyTest.php @@ -17,10 +17,8 @@ public function shouldNotBeSuspected_emptyArrayInput_emptyArrayOutput() { // given $strategy = new PregFilterSuspectedReturnStrategy([]); - // when $isSuspected = $strategy->isSuspected('', []); - // then $this->assertFalse($isSuspected); } @@ -32,10 +30,8 @@ public function shouldNotBeSuspected_arrayInput_arrayOutput() { // given $strategy = new PregFilterSuspectedReturnStrategy([1]); - // when $isSuspected = $strategy->isSuspected('', [2]); - // then $this->assertFalse($isSuspected); } @@ -47,10 +43,8 @@ public function shouldNotBeSuspected_stringInput_stringOutput() { // given $strategy = new PregFilterSuspectedReturnStrategy('input'); - // when $isSuspected = $strategy->isSuspected('', 'output'); - // then $this->assertFalse($isSuspected); } @@ -75,10 +69,8 @@ public function shouldNotBeSuspected_carefully_arrayInput_emptyArrayOutput() // given $strategy = new PregFilterSuspectedReturnStrategy(['input']); - // when $isSuspected = $strategy->isSuspected('', []); - // then $this->assertFalse($isSuspected); } @@ -90,10 +82,8 @@ public function shouldBeSuspected_stringInput_emptyArrayOutput() { // given $strategy = new PregFilterSuspectedReturnStrategy('input'); - // when $isSuspected = $strategy->isSuspected('', null); - // then $this->assertTrue($isSuspected); } diff --git a/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregReplaceSuspectedReturnStrategyTest.php b/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregReplaceSuspectedReturnStrategyTest.php index 207dc253a..f1a101bff 100644 --- a/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregReplaceSuspectedReturnStrategyTest.php +++ b/test/Legacy/SafeRegex/Internal/Guard/Strategy/PregReplaceSuspectedReturnStrategyTest.php @@ -17,10 +17,8 @@ public function shouldNotBeSuspected_emptyArrayInput_emptyArrayOutput() { // given $strategy = new PregReplaceSuspectedReturnStrategy([]); - // when $isSuspected = $strategy->isSuspected('', []); - // then $this->assertFalse($isSuspected); } @@ -32,10 +30,8 @@ public function shouldNotBeSuspected_arrayInput_arrayOutput() { // given $strategy = new PregReplaceSuspectedReturnStrategy([1]); - // when $isSuspected = $strategy->isSuspected('', [2]); - // then $this->assertFalse($isSuspected); } @@ -47,10 +43,8 @@ public function shouldNotBeSuspected_stringInput_stringOutput() { // given $strategy = new PregReplaceSuspectedReturnStrategy('input'); - // when $isSuspected = $strategy->isSuspected('', 'output'); - // then $this->assertFalse($isSuspected); } @@ -62,10 +56,8 @@ public function shouldBeSuspected_arrayInput_emptyArrayOutput() { // given $strategy = new PregReplaceSuspectedReturnStrategy(['input']); - // when $isSuspected = $strategy->isSuspected('', []); - // then $this->assertTrue($isSuspected); } @@ -77,10 +69,8 @@ public function shouldBeSuspected_stringInput_emptyArrayOutput() { // given $strategy = new PregReplaceSuspectedReturnStrategy('input'); - // when $isSuspected = $strategy->isSuspected('', null); - // then $this->assertTrue($isSuspected); } diff --git a/test/Legacy/SafeRegex/Internal/Guard/Strategy/SilencedSuspectedReturnStrategyTest.php b/test/Legacy/SafeRegex/Internal/Guard/Strategy/SilencedSuspectedReturnStrategyTest.php index 66c4e68a0..0262ab278 100644 --- a/test/Legacy/SafeRegex/Internal/Guard/Strategy/SilencedSuspectedReturnStrategyTest.php +++ b/test/Legacy/SafeRegex/Internal/Guard/Strategy/SilencedSuspectedReturnStrategyTest.php @@ -17,10 +17,8 @@ public function shouldSilence() { // given $strategy = new SilencedSuspectedReturnStrategy(); - // when $isSuspected = $strategy->isSuspected('any string', null); - // then $this->assertFalse($isSuspected); } diff --git a/test/Legacy/SafeRegex/Internal/PcreVersionTest.php b/test/Legacy/SafeRegex/Internal/PcreVersionTest.php index 1ca03e5ad..89c9df445 100644 --- a/test/Legacy/SafeRegex/Internal/PcreVersionTest.php +++ b/test/Legacy/SafeRegex/Internal/PcreVersionTest.php @@ -17,10 +17,8 @@ public function shouldGetSemanticVersionIdentity() { // given $version = new PcreVersion('13.14'); - // when $semantic = $version->semanticVersion(); - // then $this->assertSame('13.14', $semantic); } @@ -32,10 +30,8 @@ public function shouldGetSemanticVersion() { // given $version = new PcreVersion('52.23 2021-15'); - // when $semantic = $version->semanticVersion(); - // then $this->assertSame('52.23', $semantic); } @@ -47,11 +43,9 @@ public function shouldParseVersion() { // given $version = new PcreVersion('42.31'); - // when $majorVersion = $version->majorVersion(); $minorVersion = $version->minorVersion(); - // then $this->assertSame(42, $majorVersion); $this->assertSame(31, $minorVersion); @@ -64,11 +58,9 @@ public function shouldParseVersionOneDigit() { // given $version = new PcreVersion('4.1'); - // when $majorVersion = $version->majorVersion(); $minorVersion = $version->minorVersion(); - // then $this->assertSame(4, $majorVersion); $this->assertSame(1, $minorVersion); @@ -82,10 +74,8 @@ public function shouldBePcre2(string $version, bool $expected) { // given $version = new PcreVersion($version); - // when $pcre2 = $version->pcre2(); - // then $this->assertSame($expected, $pcre2); } diff --git a/test/Legacy/SafeRegex/PhpErrorTest.php b/test/Legacy/SafeRegex/PhpErrorTest.php index 1c4cd01c2..23c1d99c9 100644 --- a/test/Legacy/SafeRegex/PhpErrorTest.php +++ b/test/Legacy/SafeRegex/PhpErrorTest.php @@ -14,12 +14,10 @@ public function testGetters() { // given $error = new PhpError(E_WARNING, 'Something failed'); - // when $type = $error->getType(); $message = $error->getMessage(); $isPreg = $error->isPregError(); - // then $this->assertSame(E_WARNING, $type); $this->assertSame('Something failed', $message); @@ -33,10 +31,8 @@ public function shouldBePregError(): void { // given $error = new PhpError(0, 'preg_match()'); - // when $isPregError = $error->isPregError(); - // then $this->assertTrue($isPregError); } @@ -48,10 +44,8 @@ public function shouldNotBePregError(): void { // given $error = new PhpError(0, 'preg_ something'); - // when $isPregError = $error->isPregError(); - // then $this->assertFalse($isPregError); }