Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / dbal / tests / Doctrine / Tests / DBAL / Functional / Schema / MySqlSchemaManagerTest.php
1 <?php
2
3 namespace Doctrine\Tests\DBAL\Functional\Schema;
4
5 use Doctrine\DBAL\Schema\Table;
6 use Doctrine\DBAL\Schema\Schema;
7
8 require_once __DIR__ . '/../../../TestInit.php';
9
10 class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
11 {
12     public function testSwitchPrimaryKeyColumns()
13     {
14         $tableOld = new Table("switch_primary_key_columns");
15         $tableOld->addColumn('foo_id', 'integer');
16         $tableOld->addColumn('bar_id', 'integer');
17         $tableNew = clone $tableOld;
18
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'));
23
24         $comparator = new \Doctrine\DBAL\Schema\Comparator;
25         $this->_sm->alterTable($comparator->diffTable($tableFetched, $tableNew));
26     }
27
28     public function testDiffTableBug()
29     {
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
41
42         $this->_sm->createTable($table);
43         $tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations");
44
45         $comparator = new \Doctrine\DBAL\Schema\Comparator;
46         $diff = $comparator->diffTable($tableFetched, $table);
47
48         $this->assertFalse($diff, "no changes expected.");
49     }
50 }