wiki.techinc.nl/tests/phpunit/includes/parser/CoreParserFunctionsTest.php
Brian Wolff 5fd1e1abe0 Make Gender normalize usernames
This ensures that if GENDER is fed wfEscapeWikitext()'d version
of a username, it will normalize it.

See discussion on T182800.

Note, we do not need to worry about the case of a user named
"Project:*foo" as such namespace prefixes are illegal in
usernames.

Change-Id: Ic5a8fc76c28dca43ce8e334ef1874c2673433f00
2018-01-22 23:12:01 +00:00

21 lines
579 B
PHP

<?php
/**
* @group Database
* @covers CoreParserFunctions
*/
class CoreParserFunctionsTest extends MediaWikiTestCase {
public function testGender() {
$user = User::createNew( '*Female' );
$user->setOption( 'gender', 'female' );
$user->saveSettings();
$msg = ( new RawMessage( '{{GENDER:*Female|m|f|o}}' ) )->parse();
$this->assertEquals( $msg, 'f', 'Works unescaped' );
$escapedName = wfEscapeWikiText( '*Female' );
$msg2 = ( new RawMessage( '{{GENDER:' . $escapedName . '|m|f|o}}' ) )
->parse();
$this->assertEquals( $msg, 'f', 'Works escaped' );
}
}