Merge "Replace sorting classes with better naming convention"
[lhc/web/wiklou.git] / tests / phpunit / includes / poolcounter / PoolCounterTest.php
index d57ad04..19baf5a 100644 (file)
@@ -1,14 +1,8 @@
 <?php
 
-// We will use this class with getMockForAbstractClass to create a concrete mock class.
-// That call will die if the contructor is not public, unless we use disableOriginalConstructor(),
-// in which case we could not test the constructor.
-abstract class PoolCounterAbstractMock extends PoolCounter {
-       public function __construct() {
-               call_user_func_array( 'parent::__construct', func_get_args() );
-       }
-}
-
+/**
+ * @covers PoolCounter
+ */
 class PoolCounterTest extends MediaWikiTestCase {
        public function testConstruct() {
                $poolCounterConfig = [
@@ -18,13 +12,13 @@ class PoolCounterTest extends MediaWikiTestCase {
                        'maxqueue' => 100,
                ];
 
-               $poolCounter = $this->getMockBuilder( 'PoolCounterAbstractMock' )
+               $poolCounter = $this->getMockBuilder( PoolCounterAbstractMock::class )
                        ->setConstructorArgs( [ $poolCounterConfig, 'testCounter', 'someKey' ] )
                        // don't mock anything - the proper syntax would be setMethods(null), but due
                        // to a PHPUnit bug that does not work with getMockForAbstractClass()
                        ->setMethods( [ 'idontexist' ] )
                        ->getMockForAbstractClass();
-               $this->assertInstanceOf( 'PoolCounter', $poolCounter );
+               $this->assertInstanceOf( PoolCounter::class, $poolCounter );
        }
 
        public function testConstructWithSlots() {
@@ -36,15 +30,15 @@ class PoolCounterTest extends MediaWikiTestCase {
                        'maxqueue' => 100,
                ];
 
-               $poolCounter = $this->getMockBuilder( 'PoolCounterAbstractMock' )
+               $poolCounter = $this->getMockBuilder( PoolCounterAbstractMock::class )
                        ->setConstructorArgs( [ $poolCounterConfig, 'testCounter', 'key' ] )
                        ->setMethods( [ 'idontexist' ] ) // don't mock anything
                        ->getMockForAbstractClass();
-               $this->assertInstanceOf( 'PoolCounter', $poolCounter );
+               $this->assertInstanceOf( PoolCounter::class, $poolCounter );
        }
 
        public function testHashKeyIntoSlots() {
-               $poolCounter = $this->getMockBuilder( 'PoolCounterAbstractMock' )
+               $poolCounter = $this->getMockBuilder( PoolCounterAbstractMock::class )
                        // don't mock anything - the proper syntax would be setMethods(null), but due
                        // to a PHPUnit bug that does not work with getMockForAbstractClass()
                        ->setMethods( [ 'idontexist' ] )
@@ -79,3 +73,12 @@ class PoolCounterTest extends MediaWikiTestCase {
                );
        }
 }
+
+// We will use this class with getMockForAbstractClass to create a concrete mock class.
+// That call will die if the contructor is not public, unless we use disableOriginalConstructor(),
+// in which case we could not test the constructor.
+abstract class PoolCounterAbstractMock extends PoolCounter {
+       public function __construct() {
+               call_user_func_array( 'parent::__construct', func_get_args() );
+       }
+}