Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/90518


Change subject: Add @covers for main Database test types
......................................................................

Add @covers for main Database test types

Change-Id: I010ff5ce7afd85c7f9d528a98f2448547874b8b3
---
M tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
M tests/phpunit/includes/db/DatabaseSQLTest.php
M tests/phpunit/includes/db/DatabaseSqliteTest.php
M tests/phpunit/includes/db/DatabaseTest.php
4 files changed, 67 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/18/90518/1

diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php 
b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
index 8138b70..7d7a2bd 100644
--- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
+++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
@@ -58,6 +58,7 @@
 
        /**
         * @dataProvider provideDiapers
+        * @covers DatabaseMysqlBase::addIdentifierQuotes
         */
        function testAddIdentifierQuotes( $expected, $in ) {
                $db = new FakeDatabaseMysqlBase();
diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php 
b/tests/phpunit/includes/db/DatabaseSQLTest.php
index 46ccfe0..726d63a 100644
--- a/tests/phpunit/includes/db/DatabaseSQLTest.php
+++ b/tests/phpunit/includes/db/DatabaseSQLTest.php
@@ -6,6 +6,9 @@
  */
 class DatabaseSQLTest extends MediaWikiTestCase {
 
+       /**
+        * @var DatabaseTestHelper
+        */
        private $database;
 
        protected function setUp() {
@@ -22,6 +25,7 @@
 
        /**
         * @dataProvider provideSelect
+        * @covers DatabaseBase::select
         */
        function testSelect( $sql, $sqlText ) {
                $this->database->select(
@@ -123,6 +127,7 @@
 
        /**
         * @dataProvider provideUpdate
+        * @covers DatabaseBase::update
         */
        function testUpdate( $sql, $sqlText ) {
                $this->database->update(
@@ -174,6 +179,7 @@
 
        /**
         * @dataProvider provideDelete
+        * @covers DatabaseBase::delete
         */
        function testDelete( $sql, $sqlText ) {
                $this->database->delete(
@@ -206,6 +212,7 @@
 
        /**
         * @dataProvider provideUpsert
+        * @covers DatabaseBase::upsert
         */
        function testUpsert( $sql, $sqlText ) {
                $this->database->upsert(
@@ -241,6 +248,7 @@
 
        /**
         * @dataProvider provideDeleteJoin
+        * @covers DatabaseBase::deleteJoin
         */
        function testDeleteJoin( $sql, $sqlText ) {
                $this->database->deleteJoin(
@@ -287,6 +295,7 @@
 
        /**
         * @dataProvider provideInsert
+        * @covers DatabaseBase::insert
         */
        function testInsert( $sql, $sqlText ) {
                $this->database->insert(
@@ -339,6 +348,7 @@
 
        /**
         * @dataProvider provideInsertSelect
+        * @covers DatabaseBase::insertSelect
         */
        function testInsertSelect( $sql, $sqlText ) {
                $this->database->insertSelect(
@@ -401,6 +411,7 @@
 
        /**
         * @dataProvider provideReplace
+        * @covers DatabaseBase::replace
         */
        function testReplace( $sql, $sqlText ) {
                $this->database->replace(
@@ -515,6 +526,7 @@
 
        /**
         * @dataProvider provideNativeReplace
+        * @covers DatabaseBase::nativeReplace
         */
        function testNativeReplace( $sql, $sqlText ) {
                $this->database->nativeReplace(
@@ -541,6 +553,7 @@
 
        /**
         * @dataProvider provideConditional
+        * @covers DatabaseBase::conditional
         */
        function testConditional( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->database->conditional(
@@ -581,6 +594,7 @@
 
        /**
         * @dataProvider provideBuildConcat
+        * @covers DatabaseBase::buildConcat
         */
        function testBuildConcat( $stringList, $sqlText ) {
                $this->assertEquals( trim( $this->database->buildConcat(
@@ -603,6 +617,7 @@
 
        /**
         * @dataProvider provideBuildLike
+        * @covers DatabaseBase::buildLike
         */
        function testBuildLike( $array, $sqlText ) {
                $this->assertEquals( trim( $this->database->buildLike(
@@ -633,6 +648,7 @@
 
        /**
         * @dataProvider provideUnionQueries
+        * @covers DatabaseBase::unionQueries
         */
        function testUnionQueries( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->database->unionQueries(
@@ -667,24 +683,36 @@
                );
        }
 
+       /**
+        * @covers DatabaseBase::commit
+        */
        function testTransactionCommit() {
                $this->database->begin( __METHOD__ );
                $this->database->commit( __METHOD__ );
                $this->assertLastSql( 'BEGIN; COMMIT' );
        }
 
+       /**
+        * @covers DatabaseBase::rollback
+        */
        function testTransactionRollback() {
                $this->database->begin( __METHOD__ );
                $this->database->rollback( __METHOD__ );
                $this->assertLastSql( 'BEGIN; ROLLBACK' );
        }
 
+       /**
+        * @covers DatabaseBase::dropTable
+        */
        function testDropTable() {
                $this->database->setExistingTables( array( 'table' ) );
                $this->database->dropTable( 'table', __METHOD__ );
                $this->assertLastSql( 'DROP TABLE table' );
        }
 
+       /**
+        * @covers DatabaseBase::dropTable
+        */
        function testDropNonExistingTable() {
                $this->assertFalse(
                        $this->database->dropTable( 'non_existing', __METHOD__ )
diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php 
b/tests/phpunit/includes/db/DatabaseSqliteTest.php
index 91ab33a..f151fb2 100644
--- a/tests/phpunit/includes/db/DatabaseSqliteTest.php
+++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php
@@ -27,6 +27,10 @@
  * @group medium
  */
 class DatabaseSqliteTest extends MediaWikiTestCase {
+
+       /**
+        * @var MockDatabaseSqlite
+        */
        var $db;
 
        protected function setUp() {
@@ -83,6 +87,7 @@
 
        /**
         * @dataProvider provideAddQuotes()
+        * @covers DatabaseSqlite::addQuotes
         */
        public function testAddQuotes( $value, $expected ) {
                // check quoting
@@ -105,6 +110,9 @@
                }
        }
 
+       /**
+        * @covers DatabaseSqlite::replaceVars
+        */
        public function testReplaceVars() {
                $this->assertEquals( 'foo', $this->replaceVars( 'foo' ), "Don't 
break anything accidentally" );
 
@@ -143,6 +151,9 @@
                );
        }
 
+       /**
+        * @covers DatabaseSqlite::tableName
+        */
        public function testTableName() {
                // @todo Moar!
                $db = new DatabaseSqliteStandalone( ':memory:' );
@@ -153,6 +164,9 @@
                $this->assertEquals( 'foobar', $db->tableName( 'bar' ) );
        }
 
+       /**
+        * @covers DatabaseSqlite::duplicateTableStructure
+        */
        public function testDuplicateTableStructure() {
                $db = new DatabaseSqliteStandalone( ':memory:' );
                $db->query( 'CREATE TABLE foo(foo, barfoo)' );
@@ -174,6 +188,9 @@
                );
        }
 
+       /**
+        * @covers DatabaseSqlite::duplicateTableStructure
+        */
        public function testDuplicateTableStructureVirtual() {
                $db = new DatabaseSqliteStandalone( ':memory:' );
                if ( $db->getFulltextSearchModule() != 'FTS3' ) {
@@ -194,6 +211,9 @@
                );
        }
 
+       /**
+        * @covers DatabaseSqlite::deleteJoin
+        */
        public function testDeleteJoin() {
                $db = new DatabaseSqliteStandalone( ':memory:' );
                $db->query( 'CREATE TABLE a (a_1)', __METHOD__ );
@@ -306,12 +326,18 @@
                }
        }
 
+       /**
+        * @covers DatabaseSqlite::insertId
+        */
        public function testInsertIdType() {
                $db = new DatabaseSqliteStandalone( ':memory:' );
-               $this->assertInstanceOf( 'ResultWrapper',
-                       $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ ), 
"Database creationg" );
-               $this->assertTrue( $db->insert( 'a', array( 'a_1' => 10 ), 
__METHOD__ ),
-                       "Insertion worked" );
+
+               $databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', 
__METHOD__ );
+               $this->assertInstanceOf( 'ResultWrapper', $databaseCreation, 
"Database creation" );
+
+               $insertion = $db->insert( 'a', array( 'a_1' => 10 ), __METHOD__ 
);
+               $this->assertTrue( $insertion, "Insertion worked" );
+
                $this->assertInternalType( 'integer', $db->insertId(), "Actual 
typecheck" );
                $this->assertTrue( $db->close(), "closing database" );
        }
diff --git a/tests/phpunit/includes/db/DatabaseTest.php 
b/tests/phpunit/includes/db/DatabaseTest.php
index a3ef55a..5e8e7a4 100644
--- a/tests/phpunit/includes/db/DatabaseTest.php
+++ b/tests/phpunit/includes/db/DatabaseTest.php
@@ -5,7 +5,11 @@
  * @group DatabaseBase
  */
 class DatabaseTest extends MediaWikiTestCase {
-       var $db, $functionTest = false;
+       /**
+        * @var DatabaseBase
+        */
+       var $db;
+       var $functionTest = false;
 
        protected function setUp() {
                parent::setUp();
@@ -19,7 +23,9 @@
                        $this->functionTest = false;
                }
        }
-
+       /**
+        * @covers DatabaseBase::dropTable
+        */
        function testAddQuotesNull() {
                $check = "NULL";
                if ( $this->db->getType() === 'sqlite' || $this->db->getType() 
=== 'oracle' ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/90518
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I010ff5ce7afd85c7f9d528a98f2448547874b8b3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to