Add @covers tags to utils tests
[lhc/web/wiklou.git] / tests / phpunit / includes / utils / BatchRowUpdateTest.php
index 560b6d2..d80a61c 100644 (file)
@@ -4,6 +4,10 @@
  * Tests for BatchRowUpdate and its components
  *
  * @group db
+ *
+ * @covers BatchRowUpdate
+ * @covers BatchRowIterator
+ * @covers BatchRowWriter
  */
 class BatchRowUpdateTest extends MediaWikiTestCase {
 
@@ -36,7 +40,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
                $batchSize = 2;
                $reader = new BatchRowIterator( $db, 'some_table', 'id_field', $batchSize );
 
-               $response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function() {
+               $response = $this->genSelectResult( $batchSize, /*numRows*/ 5, function () {
                        static $i = 0;
                        return [ 'id_field' => ++$i ];
                } );
@@ -81,7 +85,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
         */
        public function testReaderGetPrimaryKey( $message, array $expected, array $row ) {
                $reader = new BatchRowIterator( $this->mockDb(), 'some_table', array_keys( $expected ), 8675309 );
-               $this->assertEquals( $expected, $reader->extractPrimaryKeys( (object) $row ), $message );
+               $this->assertEquals( $expected, $reader->extractPrimaryKeys( (object)$row ), $message );
        }
 
        public static function provider_readerSetFetchColumns() {
@@ -129,7 +133,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
                $db = $this->mockDb();
                $db->expects( $this->once() )
                        ->method( 'select' )
-                       // only testing second parameter of DatabaseBase::select
+                       // only testing second parameter of Database::select
                        ->with( 'some_table', $columns )
                        ->will( $this->returnValue( new ArrayIterator( [] ) ) );
 
@@ -164,14 +168,14 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
 
        /**
         * Slightly hackish to use reflection, but asserting different parameters
-        * to consecutive calls of DatabaseBase::select in phpunit is error prone
+        * to consecutive calls of Database::select in phpunit is error prone
         *
         * @dataProvider provider_readerSelectConditions
         */
        public function testReaderSelectConditionsMultiplePrimaryKeys(
                $message, $expectedSecondIteration, $primaryKeys, $batchSize = 3
        ) {
-               $results = $this->genSelectResult( $batchSize, $batchSize * 3, function() {
+               $results = $this->genSelectResult( $batchSize, $batchSize * 3, function () {
                        static $i = 0, $j = 100, $k = 1000;
                        return [ 'id_field' => ++$i, 'foo' => ++$j, 'bar' => ++$k ];
                } );
@@ -204,7 +208,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
                        ->will( $this->consecutivelyReturnFromSelect( $retvals ) );
                $db->expects( $this->any() )
                        ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function( $value ) {
+                       ->will( $this->returnCallback( function ( $value ) {
                                return "'$value'"; // not real quoting: doesn't matter in test
                        } ) );
 
@@ -214,7 +218,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
        protected function consecutivelyReturnFromSelect( array $results ) {
                $retvals = [];
                foreach ( $results as $rows ) {
-                       // The DatabaseBase::select method returns iterators, so we do too.
+                       // The Database::select method returns iterators, so we do too.
                        $retvals[] = $this->returnValue( new ArrayIterator( $rows ) );
                }
 
@@ -226,7 +230,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
                for ( $i = 0; $i < $numRows; $i += $batchSize ) {
                        $rows = [];
                        for ( $j = 0; $j < $batchSize && $i + $j < $numRows; $j++ ) {
-                               $rows [] = (object) call_user_func( $rowGenerator );
+                               $rows [] = (object)call_user_func( $rowGenerator );
                        }
                        $res[] = $rows;
                }
@@ -235,10 +239,9 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
        }
 
        protected function mockDb() {
-               // Cant mock from DatabaseType or DatabaseBase, they dont
-               // have the full gamut of methods
+               // @TODO: mock from Database
                // FIXME: the constructor normally sets mAtomicLevels and mSrvCache
-               $databaseMysql = $this->getMockBuilder( 'DatabaseMysql' )
+               $databaseMysql = $this->getMockBuilder( 'DatabaseMysqli' )
                        ->disableOriginalConstructor()
                        ->getMock();
                $databaseMysql->expects( $this->any() )