3 namespace Doctrine\Tests\DBAL\Functional\Schema;
5 use Doctrine\DBAL\Schema\Table;
6 use Doctrine\DBAL\Schema\Schema;
8 require_once __DIR__ . '/../../../TestInit.php';
10 class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
12 public function testSwitchPrimaryKeyColumns()
14 $tableOld = new Table("switch_primary_key_columns");
15 $tableOld->addColumn('foo_id', 'integer');
16 $tableOld->addColumn('bar_id', 'integer');
17 $tableNew = clone $tableOld;
19 $this->_sm->createTable($tableOld);
20 $tableFetched = $this->_sm->listTableDetails("switch_primary_key_columns");
21 $tableNew = clone $tableFetched;
22 $tableNew->setPrimaryKey(array('bar_id', 'foo_id'));
24 $comparator = new \Doctrine\DBAL\Schema\Comparator;
25 $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew));
28 public function testDiffTableBug()
30 $schema = new Schema();
31 $table = $schema->createTable('diffbug_routing_translations');
32 $table->addColumn('id', 'integer');
33 $table->addColumn('route', 'string');
34 $table->addColumn('locale', 'string');
35 $table->addColumn('attribute', 'string');
36 $table->addColumn('localized_value', 'string');
37 $table->addColumn('original_value', 'string');
38 $table->setPrimaryKey(array('id'));
39 $table->addUniqueIndex(array('route', 'locale', 'attribute'));
40 $table->addIndex(array('localized_value')); // this is much more selective than the unique index
42 $this->_sm->createTable($table);
43 $tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations");
45 $comparator = new \Doctrine\DBAL\Schema\Comparator;
46 $diff = $comparator->diffTable($tableFetched, $table);
48 $this->assertFalse($diff, "no changes expected.");