3 namespace MediaWiki\Tests\Installer
;
5 use MediaWiki\Installer\DatabaseUpdater
;
6 use MediaWikiIntegrationTestCase
;
7 use Wikimedia\Rdbms\IMaintainableDatabase
;
10 * @covers \MediaWiki\Installer\DatabaseUpdater
13 class DatabaseUpdaterWhenUpdateLogMissingTest
extends MediaWikiIntegrationTestCase
{
14 public function testUpdateRowExistsWhenUpdateLogTableMissing() {
15 // Check that updatelog is actually dropped, otherwise the test will still pass but not test what we want
17 $dbw = $this->getServiceContainer()->getDBLoadBalancer()->getMaintenanceConnectionRef( DB_PRIMARY
);
18 $this->assertFalse( $dbw->tableExists( 'updatelog' ) );
19 // Call the method under test.
20 $objectUnderTest = DatabaseUpdater
::newForDB( $dbw );
21 $this->assertSame( false, $objectUnderTest->updateRowExists( 'test' ) );
24 public function testInsertUpdateRowWhenUpdateLogTableMissing() {
25 // Call the method under test
26 $dbw = $this->getServiceContainer()->getDBLoadBalancer()->getMaintenanceConnectionRef( DB_PRIMARY
);
27 $objectUnderTest = DatabaseUpdater
::newForDB( $dbw );
28 $objectUnderTest->insertUpdateRow( 'test' );
29 // Check that updatelog still does not exist after calling the method under test
30 $this->assertFalse( $dbw->tableExists( 'updatelog' ) );
33 protected function getSchemaOverrides( IMaintainableDatabase
$db ) {
35 'drop' => [ 'updatelog' ],
36 'scripts' => [ __DIR__
. '/patches/drop-table-updatelog.sql' ]