Some irritating breaking changes, including dropping PHP 7.2 support and renaming the classes we care about. For now, hack in via || and some back-compatibility class aliases. Bug: T270732 Change-Id: I685f099584d2f0e5fa17f1f4275eab5289c7bfee
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
|
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
|
use Wikimedia\Rdbms\DoctrineSchemaBuilder;
|
|
use Wikimedia\Rdbms\MWPostgreSqlPlatform;
|
|
|
|
class DoctrineSchemaBuilderTest extends \PHPUnit\Framework\TestCase {
|
|
|
|
/**
|
|
* @dataProvider provideTestGetResultAllTables
|
|
* @covers \Wikimedia\Rdbms\DoctrineSchemaBuilder
|
|
*
|
|
* @param AbstractPlatform $platform
|
|
* @param string $expectedFile path fragment
|
|
*/
|
|
public function testGetResultAllTables( $platform, $expectedFile ) {
|
|
$basePath = dirname( __DIR__, 4 );
|
|
$builder = new DoctrineSchemaBuilder( $platform );
|
|
$json = file_get_contents( $basePath . '/data/db/tables.json' );
|
|
$tables = json_decode( $json, true );
|
|
|
|
foreach ( $tables as $table ) {
|
|
$builder->addTable( $table );
|
|
}
|
|
|
|
$actual = implode( "\n", $builder->getSql() );
|
|
$actual = preg_replace( "/\s*?(\n|$)/m", "", $actual );
|
|
|
|
$expected = file_get_contents( $basePath . $expectedFile );
|
|
$expected = preg_replace( "/\s*?(\n|$)/m", "", $expected );
|
|
|
|
$this->assertSame( $expected, $actual );
|
|
}
|
|
|
|
public function provideTestGetResultAllTables() {
|
|
yield 'MySQL schema tables' => [
|
|
// T270740 - HACK
|
|
class_exists( Doctrine\DBAL\Platforms\MySqlPlatform::class )
|
|
? new Doctrine\DBAL\Platforms\MySqlPlatform()
|
|
: new Doctrine\DBAL\Platforms\MySQLPlatform(),
|
|
'/data/db/mysql/tables.sql',
|
|
];
|
|
|
|
yield 'PostgreSQL schema tables' => [
|
|
new MWPostgreSqlPlatform,
|
|
'/data/db/postgres/tables.sql'
|
|
];
|
|
|
|
yield 'SQLite schema tables' => [
|
|
new SqlitePlatform,
|
|
'/data/db/sqlite/tables.sql'
|
|
];
|
|
}
|
|
}
|