Merge "Test improperly quoted attribute values in HTML tags and table cells"
[lhc/web/wiklou.git] / tests / phpunit / includes / UserTest.php
index a788253..e5a014d 100644 (file)
@@ -165,25 +165,53 @@ class UserTest extends MediaWikiTestCase {
 
        /**
         * Test User::editCount
+        * @group medium
         */
        public function testEditCount() {
                $user = User::newFromName( 'UnitTestUser' );
                $user->loadDefaults();
                $user->addToDatabase();
 
-               // let the user have a few (10) edits
-               $page = WikiPage::factory( Title::newFromText( 'UserTest_EditCount' ) );
-               for( $i = 0; $i < 10; $i++ ) {
+               // let the user have a few (3) edits
+               $page = WikiPage::factory( Title::newFromText( 'Help:UserTest_EditCount' ) );
+               for( $i = 0; $i < 3; $i++ ) {
                        $page->doEdit( (string) $i, 'test', 0, false, $user );
                }
 
                $user->clearInstanceCache();
-               $this->assertEquals( 10, $user->getEditCount(), 'After ten edits, the user edit count should be 10' );
+               $this->assertEquals( 3, $user->getEditCount(), 'After three edits, the user edit count should be 3' );
 
                // increase the edit count and clear the cache
                $user->incEditCount();
 
                $user->clearInstanceCache();
-               $this->assertEquals( 11, $user->getEditCount(), 'After increasing the edit count manually, the user edit count should be 11' );
+               $this->assertEquals( 4, $user->getEditCount(), 'After increasing the edit count manually, the user edit count should be 4' );
+       }
+
+       /**
+        * Test changing user options.
+        */
+       public function testOptions() {
+               $user = User::newFromName( 'UnitTestUser' );
+               $user->addToDatabase();
+
+               $user->setOption( 'someoption', 'test' );
+               $user->setOption( 'cols', 200 );
+               $user->saveSettings();
+
+               $user = User::newFromName( 'UnitTestUser' );
+               $this->assertEquals( 'test', $user->getOption( 'someoption' ) );
+               $this->assertEquals( 200, $user->getOption( 'cols' ) );
+       }
+
+       /**
+        * Bug 37963
+        * Make sure defaults are loaded when setOption is called.
+        */
+       public function testAnonOptions() {
+               global $wgDefaultUserOptions;
+               $this->user->setOption( 'someoption', 'test' );
+               $this->assertEquals( $wgDefaultUserOptions['cols'], $this->user->getOption( 'cols' ) );
+               $this->assertEquals( 'test', $this->user->getOption( 'someoption' ) );
        }
 }