X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flibs%2FStringUtilsTest.php;h=79d5788fa24ca6e4740ab55c4374a0da668bc0a9;hp=3e5ccacf9a45ee4d0ec5f253d5c9a57df1a08a85;hb=af80076034fb734d652eb043c523c1d8df974e51;hpb=16ef3e79c4c52aa6b74563b7eadcfc9792e7a4c4 diff --git a/tests/phpunit/includes/libs/StringUtilsTest.php b/tests/phpunit/includes/libs/StringUtilsTest.php index 3e5ccacf9a..79d5788fa2 100644 --- a/tests/phpunit/includes/libs/StringUtilsTest.php +++ b/tests/phpunit/includes/libs/StringUtilsTest.php @@ -1,6 +1,6 @@ [ $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 ] + ]; + } }