blob: 8c027a16089a048ca1f6e5f7b54f8319a0c2c4e8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php
namespace MediaWiki\Tests\Installer;
use MediaWiki\Installer\DatabaseUpdater;
use MediaWikiIntegrationTestCase;
use Wikimedia\Rdbms\IMaintainableDatabase;
/**
* @covers \MediaWiki\Installer\DatabaseUpdater
* @group Database
*/
class DatabaseUpdaterWhenUpdateLogMissingTest extends MediaWikiIntegrationTestCase {
public function testUpdateRowExistsWhenUpdateLogTableMissing() {
// Check that updatelog is actually dropped, otherwise the test will still pass but not test what we want
// it to test.
$dbw = $this->getServiceContainer()->getDBLoadBalancer()->getMaintenanceConnectionRef( DB_PRIMARY );
$this->assertFalse( $dbw->tableExists( 'updatelog' ) );
// Call the method under test.
$objectUnderTest = DatabaseUpdater::newForDB( $dbw );
$this->assertSame( false, $objectUnderTest->updateRowExists( 'test' ) );
}
public function testInsertUpdateRowWhenUpdateLogTableMissing() {
// Call the method under test
$dbw = $this->getServiceContainer()->getDBLoadBalancer()->getMaintenanceConnectionRef( DB_PRIMARY );
$objectUnderTest = DatabaseUpdater::newForDB( $dbw );
$objectUnderTest->insertUpdateRow( 'test' );
// Check that updatelog still does not exist after calling the method under test
$this->assertFalse( $dbw->tableExists( 'updatelog' ) );
}
protected function getSchemaOverrides( IMaintainableDatabase $db ) {
return [
'drop' => [ 'updatelog' ],
'scripts' => [ __DIR__ . '/patches/drop-table-updatelog.sql' ]
];
}
}
|