From: Fomafix Date: Fri, 30 Jun 2017 10:20:19 +0000 (+0200) Subject: Add tests for Sanitizer::escapeId X-Git-Tag: 1.31.0-rc.0~2597 X-Git-Url: http://git.cyclocoop.org/%22.%24redirect_annul.%22?a=commitdiff_plain;h=6499795f8641c6e44dde9e40a34c7b23de6963e3;p=lhc%2Fweb%2Fwiklou.git Add tests for Sanitizer::escapeId The tests are transfered from mediawiki.util.test.js. Change-Id: I3fccfab3a2cdf5ad115fc426b3d45ce905e2e609 --- diff --git a/tests/phpunit/includes/SanitizerTest.php b/tests/phpunit/includes/SanitizerTest.php index abcf1d4283..6d093b0f13 100644 --- a/tests/phpunit/includes/SanitizerTest.php +++ b/tests/phpunit/includes/SanitizerTest.php @@ -343,6 +343,41 @@ class SanitizerTest extends MediaWikiTestCase { ]; } + /** + * Test Sanitizer::escapeId + * + * @dataProvider provideEscapeId + * @covers Sanitizer::escapeId + */ + public function testEscapeId( $input, $output ) { + $this->assertEquals( + $output, + Sanitizer::escapeId( $input, [ 'noninitial', 'legacy' ] ) + ); + } + + public static function provideEscapeId() { + return [ + [ '+', '.2B' ], + [ '&', '.26' ], + [ '=', '.3D' ], + [ ':', ':' ], + [ ';', '.3B' ], + [ '@', '.40' ], + [ '$', '.24' ], + [ '-_.', '-_.' ], + [ '!', '.21' ], + [ '*', '.2A' ], + [ '/', '.2F' ], + [ '[]', '.5B.5D' ], + [ '<>', '.3C.3E' ], + [ '\'', '.27' ], + [ '§', '.C2.A7' ], + [ 'Test:A & B/Here', 'Test:A_.26_B.2FHere' ], + [ 'A&B&C&amp;D&amp;amp;E', 'A.26B.26C.26amp.3BD.26amp.3Bamp.3BE' ], + ]; + } + /** * Test escapeIdReferenceList for consistency with escapeId *