Move DatabaseDomain to Rdbms namespace
[lhc/web/wiklou.git] / tests / phpunit / includes / db / DatabaseMysqlBaseTest.php
index 9480c2d..1524b78 100644 (file)
  * @copyright © 2013 Wikimedia Foundation Inc.
  */
 
+use Wikimedia\Rdbms\TransactionProfiler;
+use Wikimedia\Rdbms\DatabaseDomain;
+
 /**
  * Fake class around abstract class so we can call concrete methods.
  */
 class FakeDatabaseMysqlBase extends DatabaseMysqlBase {
-       // From DatabaseBase
+       // From Database
        function __construct() {
                $this->profiler = new ProfilerStub( [] );
                $this->trxProfiler = new TransactionProfiler();
@@ -89,7 +92,6 @@ class FakeDatabaseMysqlBase extends DatabaseMysqlBase {
 
        }
 
-       // From interface DatabaseType
        function insertId() {
        }
 
@@ -171,23 +173,19 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase {
        }
 
        function getMockForViews() {
-               $db = $this->getMockBuilder( 'DatabaseMysql' )
+               $db = $this->getMockBuilder( 'DatabaseMysqli' )
                        ->disableOriginalConstructor()
                        ->setMethods( [ 'fetchRow', 'query' ] )
                        ->getMock();
 
                $db->method( 'query' )
                        ->with( $this->anything() )
-                       ->willReturn( null );
+                       ->willReturn( new FakeResultWrapper( [
+                               (object)[ 'Tables_in_' => 'view1' ],
+                               (object)[ 'Tables_in_' => 'view2' ],
+                               (object)[ 'Tables_in_' => 'myview' ]
+                       ] ) );
 
-               $db->method( 'fetchRow' )
-                       ->with( $this->anything() )
-                       ->will( $this->onConsecutiveCalls(
-                               [ 'Tables_in_' => 'view1' ],
-                               [ 'Tables_in_' => 'view2' ],
-                               [ 'Tables_in_' => 'myview' ],
-                               false  # no more rows
-                       ) );
                return $db;
        }
        /**
@@ -196,9 +194,6 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase {
        function testListviews() {
                $db = $this->getMockForViews();
 
-               // The first call populate an internal cache of views
-               $this->assertEquals( [ 'view1', 'view2', 'myview' ],
-                       $db->listViews() );
                $this->assertEquals( [ 'view1', 'view2', 'myview' ],
                        $db->listViews() );
 
@@ -213,42 +208,6 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase {
                        $db->listViews( '' ) );
        }
 
-       /**
-        * @covers DatabaseMysqlBase::isView
-        * @dataProvider provideViewExistanceChecks
-        */
-       function testIsView( $isView, $viewName ) {
-               $db = $this->getMockForViews();
-
-               switch ( $isView ) {
-                       case true:
-                               $this->assertTrue( $db->isView( $viewName ),
-                                       "$viewName should be considered a view" );
-                       break;
-
-                       case false:
-                               $this->assertFalse( $db->isView( $viewName ),
-                                       "$viewName has not been defined as a view" );
-                       break;
-               }
-
-       }
-
-       function provideViewExistanceChecks() {
-               return [
-                       // format: whether it is a view, view name
-                       [ true, 'view1' ],
-                       [ true, 'view2' ],
-                       [ true, 'myview' ],
-
-                       [ false, 'user' ],
-
-                       [ false, 'view10' ],
-                       [ false, 'my' ],
-                       [ false, 'OH_MY_GOD' ],  # they killed kenny!
-               ];
-       }
-
        /**
         * @dataProvider provideComparePositions
         */
@@ -358,7 +317,7 @@ class DatabaseMysqlBaseTest extends MediaWikiTestCase {
         * @dataProvider provideLagAmounts
         */
        function testPtHeartbeat( $lag ) {
-               $db = $this->getMockBuilder( 'DatabaseMysql' )
+               $db = $this->getMockBuilder( 'DatabaseMysqli' )
                        ->disableOriginalConstructor()
                        ->setMethods( [
                                'getLagDetectionMethod', 'getHeartbeatData', 'getMasterServerInfo' ] )