X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fphpunit%2Fincludes%2Flibs%2FStringUtilsTest.php;h=79d5788fa24ca6e4740ab55c4374a0da668bc0a9;hb=a1ef77b2d80830fbcb617a83961d78cff9d6e384;hp=8075944e64bbb0b05a9b58566584911c740d7d74;hpb=29906d505b9b3d5f0fd1e6534f077b7fe2c623dc;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/libs/StringUtilsTest.php b/tests/phpunit/includes/libs/StringUtilsTest.php index 8075944e64..79d5788fa2 100644 --- a/tests/phpunit/includes/libs/StringUtilsTest.php +++ b/tests/phpunit/includes/libs/StringUtilsTest.php @@ -1,6 +1,8 @@ [ $PASS, "\xef\xbf\xbf" ], ]; } + + /** + * @param strin $input + * @param bool $expected + * @dataProvider provideRegexps + * @covers StringUtils::isValidRegex + */ + public function testIsValidRegex( $input, $expected ) { + $this->assertSame( $expected, StringUtils::isValidRegex( $input ) ); + } + + /** + * Data provider for testValidRegex + */ + public static function provideRegexps() { + return [ + [ 'foo', false ], + [ '/foo/', true ], + [ '//', true ], + [ '/(foo/', false ], + [ '!(f[o]{2})!', true ], + [ '/foo\/', false ] + ]; + } }