Merge "Document return of void in Maintenance::execute"
[lhc/web/wiklou.git] / tests / phpunit / tests / MediaWikiTestCaseSchema1Test.php
1 <?php
2 use Wikimedia\Rdbms\IMaintainableDatabase;
3
4 /**
5 * @covers MediaWikiTestCase
6 *
7 * @group Database
8 * @group MediaWikiTestCaseTest
9 */
10 class MediaWikiTestCaseSchema1Test extends MediaWikiTestCase {
11
12 public static $hasRun = false;
13
14 public function setUp() {
15 parent::setUp();
16 if ( $this->db->getType() == 'postgres' ) {
17 $this->markTestSkipped( __CLASS__ . ' does not support postgres' );
18 }
19 }
20
21 public function getSchemaOverrides( IMaintainableDatabase $db ) {
22 return [
23 'create' => [ 'MediaWikiTestCaseTestTable', 'imagelinks' ],
24 'drop' => [ 'oldimage' ],
25 'alter' => [ 'pagelinks' ],
26 'scripts' => [ __DIR__ . '/MediaWikiTestCaseSchemaTest.sql' ]
27 ];
28 }
29
30 public function testMediaWikiTestCaseSchemaTestOrder() {
31 // The test must be run before the second test
32 self::$hasRun = true;
33 $this->assertTrue( self::$hasRun );
34 }
35
36 public function testTableWasCreated() {
37 // Make sure MediaWikiTestCaseTestTable was created.
38 $this->assertTrue( $this->db->tableExists( 'MediaWikiTestCaseTestTable' ) );
39 }
40
41 public function testTableWasDropped() {
42 // Make sure oldimage was dropped
43 $this->assertFalse( $this->db->tableExists( 'oldimage' ) );
44 }
45
46 public function testTableWasOverriden() {
47 // Make sure imagelinks was overwritten
48 $this->assertTrue( $this->db->tableExists( 'imagelinks' ) );
49 $this->assertTrue( $this->db->fieldExists( 'imagelinks', 'il_frobnitz' ) );
50 }
51
52 public function testTableWasAltered() {
53 // Make sure pagelinks was altered
54 $this->assertTrue( $this->db->tableExists( 'pagelinks' ) );
55 $this->assertTrue( $this->db->fieldExists( 'pagelinks', 'pl_frobnitz' ) );
56 }
57
58 }