public function testGetCanonicalName( $name, $expectedArray, $msg ) {
foreach ( $expectedArray as $validate => $expected ) {
$this->assertEquals(
- User::getCanonicalName( $name, $validate === 'false' ? false : $validate ),
$expected,
+ User::getCanonicalName( $name, $validate === 'false' ? false : $validate ),
$msg . ' (' . $validate . ')'
);
}
public static function provideGetCanonicalName() {
return array(
- array( ' trailing space ', array( 'creatable' => 'Trailing space' ), 'Trailing spaces' ),
+ array( ' Trailing space ', array( 'creatable' => 'Trailing space' ), 'Trailing spaces' ),
// @todo FIXME: Maybe the creatable name should be 'Talk:Username' or false to reject?
array( 'Talk:Username', array( 'creatable' => 'Username', 'usable' => 'Username',
'valid' => 'Username', 'false' => 'Talk:Username' ), 'Namespace prefix' ),
'false' => 'With / slash' ), 'With slash' ),
);
}
+
+ /**
+ * @covers User::equals
+ */
+ public function testEquals() {
+ $first = User::newFromName( 'EqualUser' );
+ $second = User::newFromName( 'EqualUser' );
+
+ $this->assertTrue( $first->equals( $first ) );
+ $this->assertTrue( $first->equals( $second ) );
+ $this->assertTrue( $second->equals( $first ) );
+
+ $third = User::newFromName( '0' );
+ $fourth = User::newFromName( '000' );
+
+ $this->assertFalse( $third->equals( $fourth ) );
+ $this->assertFalse( $fourth->equals( $third ) );
+
+ // Test users loaded from db with id
+ $user = User::newFromName( 'EqualUnitTestUser' );
+ if ( !$user->getId() ) {
+ $user->addToDatabase();
+ }
+
+ $id = $user->getId();
+
+ $fifth = User::newFromId( $id );
+ $sixth = User::newFromName( 'EqualUnitTestUser' );
+ $this->assertTrue( $fifth->equals( $sixth ) );
+ }
}