From: Santhosh Thottingal Date: Tue, 11 Oct 2011 09:17:36 +0000 (+0000) Subject: Testcases for isValidUserName method of User.php. X-Git-Tag: 1.31.0-rc.0~27152 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=2a7c8be0247d36fb5b99d56341474c029f2d4b94;p=lhc%2Fweb%2Fwiklou.git Testcases for isValidUserName method of User.php. There are many cases this method will fail for non-latin languages, but not added now since there are bugs reported on that already and results a rewrite of the method as per UAX 31 standard. --- diff --git a/tests/phpunit/includes/UserTest.php b/tests/phpunit/includes/UserTest.php index 99b6e7f61d..bc87ede285 100644 --- a/tests/phpunit/includes/UserTest.php +++ b/tests/phpunit/includes/UserTest.php @@ -164,4 +164,22 @@ class UserTest extends MediaWikiTestCase { ), ); } + + public function testIsValidUserName() { + $this->assertFalse( $this->user->isValidUserName( '' ) ); + $this->assertFalse( $this->user->isValidUserName( ' ' ) ); + $this->assertFalse( $this->user->isValidUserName( 'abcd' ) ); + $this->assertFalse( $this->user->isValidUserName( 'Ab/cd' ) ); + $this->assertTrue( $this->user->isValidUserName( 'Ab cd' ) ); // Whitespace + $this->assertFalse( $this->user->isValidUserName( '192.168.1.1' ) ); // IP + $this->assertFalse( $this->user->isValidUserName( 'User:Abcd' ) ); // Reserved Namespace + $this->assertTrue( $this->user->isValidUserName( '12abcd232' ) ); + $this->assertTrue( $this->user->isValidUserName( '12abcd.232' ) ); + $this->assertTrue( $this->user->isValidUserName( '?abcd' ) ); + $this->assertFalse( $this->user->isValidUserName( '#abcd' ) ); + $this->assertTrue( $this->user->isValidUserName( 'Abcdകഖഗഘ' ) ); // Mixed scripts + $this->assertFalse( $this->user->isValidUserName( 'ജോസ്‌തോമസ്' ) ); // ZWNJ + $this->assertFalse( $this->user->isValidUserName( 'Ab cd' ) ); // Ideographic space + } + }