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=fcfa53e22df724170edcbac8fdb4f6c596922aef;hb=c14571ba26edbe26606127fdf89cd9793a7488ab;hpb=2083ba21997bc214c34a5a1edbeef61b0cb98981 diff --git a/tests/phpunit/includes/libs/StringUtilsTest.php b/tests/phpunit/includes/libs/StringUtilsTest.php index fcfa53e22d..79d5788fa2 100644 --- a/tests/phpunit/includes/libs/StringUtilsTest.php +++ b/tests/phpunit/includes/libs/StringUtilsTest.php @@ -125,4 +125,28 @@ class StringUtilsTest extends PHPUnit\Framework\TestCase { 'noncharacters 2' => [ $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 ] + ]; + } }