The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
use Wikimedia\Rdbms\Database;
|
|
|
|
/**
|
|
* @group Database
|
|
*/
|
|
class DatabaseIntegrationTest extends MediaWikiIntegrationTestCase {
|
|
/**
|
|
* @var Database
|
|
*/
|
|
protected $db;
|
|
|
|
protected function setUp() : void {
|
|
parent::setUp();
|
|
$this->db = wfGetDB( DB_MASTER );
|
|
}
|
|
|
|
public function testUnknownTableCorruptsResults() {
|
|
$res = $this->db->select( 'page', '*', [ 'page_id' => 1 ] );
|
|
$this->assertFalse( $this->db->tableExists( 'foobarbaz' ) );
|
|
$this->assertIsInt( $res->numRows() );
|
|
}
|
|
|
|
public function automaticSqlGenerationParams() {
|
|
return [
|
|
[ 'mysql' ],
|
|
[ 'sqlite' ],
|
|
[ 'postgres' ],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider automaticSqlGenerationParams
|
|
*/
|
|
public function testAutomaticSqlGeneration( $type ) {
|
|
global $IP;
|
|
$abstractSchemaPath = "$IP/maintenance/tables.json";
|
|
if ( $type === 'mysql' ) {
|
|
$oldPath = "$IP/maintenance/tables-generated.sql";
|
|
} else {
|
|
$oldPath = "$IP/maintenance/$type/tables-generated.sql";
|
|
}
|
|
$oldContent = file_get_contents( $oldPath );
|
|
$newPath = $this->getNewTempFile();
|
|
$maintenanceScript = new GenerateSchemaSql();
|
|
$maintenanceScript->loadWithArgv(
|
|
[ '--json=' . $abstractSchemaPath, '--sql=' . $newPath, '--type=' . $type ]
|
|
);
|
|
$maintenanceScript->execute();
|
|
$this->assertEquals(
|
|
$oldContent,
|
|
file_get_contents( $newPath ),
|
|
"The generated schema in '$type' type has to be the same"
|
|
);
|
|
}
|
|
}
|