Now that we merged DatabaseMysqli with DatabaseMysqlBase, there is no base anymore. I could have gone with DatabaseMysql, and the naming is not that consistent in rdbms: amir@amir-ThinkPad-P1-Gen-3:~/core/includes/libs/rdbms$ find . | grep -i mysql ./platform/MySQLPlatform.php ./field/MySQLField.php ./dbal/MWMySQLPlatform.php ./database/DatabaseMysqlBase.php ./database/DatabaseMysqli.php ./database/position/MySQLPrimaryPos.php ./database/resultwrapper/MysqliResultWrapper.php ./database/replication/MysqlReplicationReporter.php The majority is MySQL and since it's the correct form, I went with that instead. Change-Id: I3ee792f357dda974c855ba24b9b35e72fc73db06
42 lines
1.5 KiB
PHP
42 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Wikimedia\Rdbms\Database;
|
|
use Wikimedia\Rdbms\DatabaseFactory;
|
|
use Wikimedia\Rdbms\DatabaseMySQL;
|
|
use Wikimedia\Rdbms\DatabasePostgres;
|
|
use Wikimedia\Rdbms\DatabaseSqlite;
|
|
|
|
/**
|
|
* @covers Wikimedia\Rdbms\DatabaseFactory
|
|
*/
|
|
class DatabaseFactoryTest extends PHPUnit\Framework\TestCase {
|
|
|
|
use MediaWikiCoversValidator;
|
|
|
|
public function testFactory() {
|
|
$factory = new DatabaseFactory();
|
|
$m = Database::NEW_UNCONNECTED; // no-connect mode
|
|
$p = [
|
|
'host' => 'localhost',
|
|
'serverName' => 'localdb',
|
|
'user' => 'me',
|
|
'password' => 'myself',
|
|
'dbname' => 'i'
|
|
];
|
|
|
|
$this->assertInstanceOf( DatabaseMySQL::class, $factory->create( 'mysql', $p, $m ) );
|
|
$this->assertInstanceOf( DatabaseMySQL::class, $factory->create( 'MySql', $p, $m ) );
|
|
$this->assertInstanceOf( DatabaseMySQL::class, $factory->create( 'MySQL', $p, $m ) );
|
|
$this->assertInstanceOf( DatabasePostgres::class, $factory->create( 'postgres', $p, $m ) );
|
|
$this->assertInstanceOf( DatabasePostgres::class, $factory->create( 'Postgres', $p, $m ) );
|
|
|
|
$x = $p + [ 'dbFilePath' => 'some/file.sqlite' ];
|
|
$this->assertInstanceOf( DatabaseSqlite::class, $factory->create( 'sqlite', $x, $m ) );
|
|
$x = $p + [ 'dbDirectory' => 'some/file' ];
|
|
$this->assertInstanceOf( DatabaseSqlite::class, $factory->create( 'sqlite', $x, $m ) );
|
|
|
|
$conn = $factory->create( 'sqlite', $p, $m );
|
|
$this->assertEquals( 'localhost', $conn->getServer() );
|
|
$this->assertEquals( 'localdb', $conn->getServerName() );
|
|
}
|
|
}
|