Merge "Message: Clean up unit tests and improve code coverage"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 2 Apr 2015 13:25:28 +0000 (13:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 2 Apr 2015 13:25:28 +0000 (13:25 +0000)
includes/profiler/Profiler.php
tests/phpunit/includes/UserTest.php

index 0718875..924bb03 100644 (file)
@@ -49,7 +49,7 @@ abstract class Profiler {
                'text' => 'ProfilerOutputText',
                'udp' => 'ProfilerOutputUdp',
                'dump' => 'ProfilerOutputDump',
-               'context' => 'ProfilerOutputStats',
+               'stats' => 'ProfilerOutputStats',
        );
 
        /** @var Profiler */
index 73e5051..b74a7ea 100644 (file)
@@ -397,4 +397,32 @@ class UserTest extends MediaWikiTestCase {
                $sixth = User::newFromName( 'EqualUnitTestUser' );
                $this->assertTrue( $fifth->equals( $sixth ) );
        }
+
+       /**
+        * @covers User::getId
+        */
+       public function testGetId() {
+               $user = User::newFromName( 'UTSysop' );
+               $this->assertTrue( $user->getId() > 0 );
+
+       }
+
+       /**
+        * @covers User::isLoggedIn
+        * @covers User::isAnon
+        */
+       public function testLoggedIn() {
+               $user = User::newFromName( 'UTSysop' );
+               $this->assertTrue( $user->isLoggedIn() );
+               $this->assertFalse( $user->isAnon() );
+
+               // Non-existent users are perceived as anonymous
+               $user = User::newFromName( 'UTNonexistent' );
+               $this->assertFalse( $user->isLoggedIn() );
+               $this->assertTrue( $user->isAnon() );
+
+               $user = new User;
+               $this->assertFalse( $user->isLoggedIn() );
+               $this->assertTrue( $user->isAnon() );
+       }
 }