objectcache: add setMockTime() method to BagOStuff/WANObjectCache
[lhc/web/wiklou.git] / tests / phpunit / tests / MediaWikiTestCaseSchema1Test.php
index 6f94494..d794d13 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+use Wikimedia\Rdbms\IMaintainableDatabase;
 
 /**
  * @covers MediaWikiTestCase
@@ -10,10 +11,12 @@ class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase {
 
        public static $hasRun = false;
 
-       public function getSchemaOverrides() {
+       public function getSchemaOverrides( IMaintainableDatabase $db ) {
                return [
-                       [ 'imagelinks', 'MediaWikiTestCaseTestTable' ],
-                       [ __DIR__ . '/MediaWikiTestCaseSchemaTest.sql' ]
+                       'create' => [ 'MediaWikiTestCaseTestTable', 'imagelinks' ],
+                       'drop' => [ 'oldimage' ],
+                       'alter' => [ 'pagelinks' ],
+                       'scripts' => [ __DIR__ . '/MediaWikiTestCaseSchemaTest.sql' ]
                ];
        }
 
@@ -23,37 +26,26 @@ class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase {
                $this->assertTrue( self::$hasRun );
        }
 
-       public function testSchemaExtension() {
-               // make sure we can use the MediaWikiTestCaseTestTable table
-
-               $input = [ 'id' => '5', 'name' => 'Test' ];
-
-               $this->db->insert(
-                       'MediaWikiTestCaseTestTable',
-                       $input
-               );
-
-               $output = $this->db->selectRow( 'MediaWikiTestCaseTestTable', array_keys( $input ), [] );
-               $this->assertEquals( (object)$input, $output );
+       public function testTableWasCreated() {
+               // Make sure MediaWikiTestCaseTestTable was created.
+               $this->assertTrue( $this->db->tableExists( 'MediaWikiTestCaseTestTable' ) );
        }
 
-       public function testSchemaOverride() {
-               // make sure we can use the il_frobniz field
-
-               $input = [
-                       'il_from' => '7',
-                       'il_from_namespace' => '0',
-                       'il_to' => 'Foo.jpg',
-                       'il_frobniz' => 'Xyzzy',
-               ];
+       public function testTableWasDropped() {
+               // Make sure oldimage was dropped
+               $this->assertFalse( $this->db->tableExists( 'oldimage' ) );
+       }
 
-               $this->db->insert(
-                       'imagelinks',
-                       $input
-               );
+       public function testTableWasOverriden() {
+               // Make sure imagelinks was overwritten
+               $this->assertTrue( $this->db->tableExists( 'imagelinks' ) );
+               $this->assertTrue( $this->db->fieldExists( 'imagelinks', 'il_frobnitz' ) );
+       }
 
-               $output = $this->db->selectRow( 'imagelinks', array_keys( $input ), [] );
-               $this->assertEquals( (object)$input, $output );
+       public function testTableWasAltered() {
+               // Make sure pagelinks was altered
+               $this->assertTrue( $this->db->tableExists( 'pagelinks' ) );
+               $this->assertTrue( $this->db->fieldExists( 'pagelinks', 'pl_frobnitz' ) );
        }
 
 }