aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/UserTest.php
diff options
context:
space:
mode:
authorumherirrender <umherirrender_de.wp@web.de>2014-08-25 20:24:10 +0200
committerUmherirrender <umherirrender_de.wp@web.de>2014-09-05 13:46:00 +0000
commitf3dbe5ba365dbdf05965eeb2a6ea8a92d92d9fed (patch)
tree37773901d41656efb458c7984c6ac8675a612bd7 /tests/phpunit/includes/UserTest.php
parent6b9a1c6d5b96dd55b05b9db5d4ab864973b7ff8f (diff)
downloadmediawikicore-f3dbe5ba365dbdf05965eeb2a6ea8a92d92d9fed.tar.gz
mediawikicore-f3dbe5ba365dbdf05965eeb2a6ea8a92d92d9fed.zip
Add tests for User::getCanonicalName()
Change-Id: I00097a4706c4ada41a5697470b550c925ae6051d
Diffstat (limited to 'tests/phpunit/includes/UserTest.php')
-rw-r--r--tests/phpunit/includes/UserTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/phpunit/includes/UserTest.php b/tests/phpunit/includes/UserTest.php
index 36de114ead67..cabbf10fc092 100644
--- a/tests/phpunit/includes/UserTest.php
+++ b/tests/phpunit/includes/UserTest.php
@@ -323,4 +323,35 @@ class UserTest extends MediaWikiTestCase {
$this->assertFalse( $user->checkPasswordValidity( 'Passpass' )->isGood() );
$this->assertEquals( 'password-login-forbidden', $user->getPasswordValidity( 'Passpass' ) );
}
+
+ /**
+ * @covers User::getCanonicalName()
+ * @dataProvider provideGetCanonicalName
+ */
+ public function testGetCanonicalName( $name, $expectedArray, $msg ) {
+ foreach ( $expectedArray as $validate => $expected ) {
+ $this->assertEquals(
+ User::getCanonicalName( $name, $validate === 'false' ? false : $validate ),
+ $expected,
+ $msg . ' (' . $validate . ')'
+ );
+ }
+ }
+
+ public function provideGetCanonicalName() {
+ return array(
+ array( ' trailing space ', array( 'creatable' => 'Trailing space' ), 'Trailing spaces' ),
+ // @todo FIXME: Maybe the createable name should be 'Talk:Username' or false to reject?
+ array( 'Talk:Username', array( 'creatable' => 'Username', 'usable' => 'Username',
+ 'valid' => 'Username', 'false' => 'Talk:Username' ), 'Namespace prefix' ),
+ array( ' name with # hash', array( 'creatable' => false, 'usable' => false ), 'With hash' ),
+ array( 'Multi spaces', array( 'creatable' => 'Multi spaces',
+ 'usable' => 'Multi spaces' ), 'Multi spaces' ),
+ array( 'lowercase', array( 'creatable' => 'Lowercase' ), 'Lowercase' ),
+ array( 'in[]valid', array( 'creatable' => false, 'usable' => false, 'valid' => false,
+ 'false' => 'In[]valid' ), 'Invalid' ),
+ array( 'with / slash', array( 'creatable' => false, 'usable' => false, 'valid' => false,
+ 'false' => 'With / slash' ), 'With slash' ),
+ );
+ }
}