X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Fdbal%2Ftests%2FDoctrine%2FTests%2FDBAL%2FSchema%2FPlatforms%2FMySQLSchemaTest.php;fp=vendor%2Fdoctrine%2Fdbal%2Ftests%2FDoctrine%2FTests%2FDBAL%2FSchema%2FPlatforms%2FMySQLSchemaTest.php;h=651a5ee23e85ecf313683c801e8e0c62b3afdf80;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fgalerie.git diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php new file mode 100644 index 0000000..651a5ee --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php @@ -0,0 +1,88 @@ +comparator = new \Doctrine\DBAL\Schema\Comparator; + $this->platform = new \Doctrine\DBAL\Platforms\MySqlPlatform; + } + + public function testSwitchPrimaryKeyOrder() + { + $tableOld = new Table("test"); + $tableOld->addColumn('foo_id', 'integer'); + $tableOld->addColumn('bar_id', 'integer'); + $tableNew = clone $tableOld; + + $tableOld->setPrimaryKey(array('foo_id', 'bar_id')); + $tableNew->setPrimaryKey(array('bar_id', 'foo_id')); + + $diff = $this->comparator->diffTable($tableOld, $tableNew); + $sql = $this->platform->getAlterTableSQL($diff); + + $this->assertEquals( + array( + 'ALTER TABLE test DROP PRIMARY KEY', + 'ALTER TABLE test ADD PRIMARY KEY (bar_id, foo_id)' + ), $sql + ); + } + + /** + * @group DBAL-132 + */ + public function testGenerateForeignKeySQL() + { + $tableOld = new Table("test"); + $tableOld->addColumn('foo_id', 'integer'); + $tableOld->addUnnamedForeignKeyConstraint('test_foreign', array('foo_id'), array('foo_id')); + + $sqls = array(); + foreach ($tableOld->getForeignKeys() AS $fk) { + $sqls[] = $this->platform->getCreateForeignKeySQL($fk, $tableOld); + } + + $this->assertEquals(array("ALTER TABLE test ADD CONSTRAINT FK_D87F7E0C8E48560F FOREIGN KEY (foo_id) REFERENCES test_foreign (foo_id)"), $sqls); + } + + /** + * @group DDC-1737 + */ + public function testClobNoAlterTable() + { + $tableOld = new Table("test"); + $tableOld->addColumn('id', 'integer'); + $tableOld->addColumn('description', 'string', array('length' => 65536)); + $tableNew = clone $tableOld; + + $tableNew->setPrimaryKey(array('id')); + + $diff = $this->comparator->diffTable($tableOld, $tableNew); + $sql = $this->platform->getAlterTableSQL($diff); + + $this->assertEquals( + array('ALTER TABLE test ADD PRIMARY KEY (id)'), + $sql + ); + } +} \ No newline at end of file