public function providerForTestGetModifyTableForeignKeysSkipSql2DDL() { $schema1 = <<<EOF <database name="test"> \t<table name="foo1"> \t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> \t\t<column name="bar" type="INTEGER" /> \t\t<foreign-key name="foo1_FK_1" foreignTable="foo2" skipSql="true"> \t\t\t<reference local="bar" foreign="bar" /> \t\t</foreign-key> \t</table> \t<table name="foo2"> \t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> \t\t<column name="bar" type="INTEGER" /> \t</table> </database> EOF; $schema2 = <<<EOF <database name="test"> \t<table name="foo1"> \t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> \t\t<column name="bar" type="INTEGER" /> \t</table> \t<table name="foo2"> \t\t<column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" /> \t\t<column name="bar" type="INTEGER" /> \t</table> </database> EOF; $t1 = $this->getDatabaseFromSchema($schema1)->getTable('foo1'); $t2 = $this->getDatabaseFromSchema($schema2)->getTable('foo1'); $tc = new PropelTableComparator(); $tc->setFromTable($t1); $tc->setToTable($t2); $tc->compareForeignKeys(); return array(array($tc->getTableDiff())); }
public function testCompareModifiedFks() { $db1 = new Database(); $db1->setPlatform($this->platform); $c1 = new Column('Foo'); $c2 = new Column('Bar'); $fk1 = new ForeignKey(); $fk1->addReference($c1, $c2); $t1 = new Table('Baz'); $t1->addForeignKey($fk1); $db1->addTable($t1); $t1->doNaming(); $db2 = new Database(); $db2->setPlatform($this->platform); $c3 = new Column('Foo'); $c4 = new Column('Bar2'); $fk2 = new ForeignKey(); $fk2->addReference($c3, $c4); $t2 = new Table('Baz'); $t2->addForeignKey($fk2); $db2->addTable($t2); $t2->doNaming(); $tc = new PropelTableComparator(); $tc->setFromTable($t1); $tc->setToTable($t2); $nbDiffs = $tc->compareForeignKeys(); $tableDiff = $tc->getTableDiff(); $this->assertEquals(1, $nbDiffs); $this->assertEquals(1, count($tableDiff->getModifiedFks())); $this->assertEquals(array('Baz_FK_1' => array($fk1, $fk2)), $tableDiff->getModifiedFks()); }