wiki.techinc.nl/tests/phpunit/includes/libs/rdbms/database/DoctrineSchemaBuilderTest.php
Amir Sarabadani 6d4dc90831 Improve tests in DoctrineSchemaBuilder
Also changing its structure to be more readable and more like
https://w.wiki/CXo

My plan is to add more tables to this test.

Bug: T230428
Change-Id: Ia19d5c875cc95238f7fd7cd9adbed1ddb92af078
2019-11-22 19:53:10 +01:00

29 lines
842 B
PHP

<?php
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Wikimedia\Rdbms\DoctrineSchemaBuilder;
class DoctrineSchemaBuilderTest extends \PHPUnit\Framework\TestCase {
/**
* @covers \Wikimedia\Rdbms\DoctrineSchemaBuilder
*/
public function testGetResultAllTables() {
$platform = new MySqlPlatform();
$builder = new DoctrineSchemaBuilder( $platform );
$tables = json_decode( file_get_contents( __DIR__ . '/../../../../data/db/tables.json' ), true );
$expected = file_get_contents( __DIR__ . '/../../../../data/db/mysql/tables.sql' );
foreach ( $tables as $table ) {
$builder->addTable( $table );
}
$actual = implode( "\n", $builder->getSql() );
$actual = preg_replace( "/\s*?(\n|$)/m", "", $actual );
$expected = preg_replace( "/\s*?(\n|$)/m", "", $expected );
$this->assertSame(
$expected,
$actual
);
}
}