Commit c2f626fa authored by Steve Müller's avatar Steve Müller

cover an additional case of avoiding multi drop foreign key avoid in tests

parent ed7e49bb
...@@ -980,22 +980,33 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase ...@@ -980,22 +980,33 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
{ {
$oldSchema = new Schema(); $oldSchema = new Schema();
$tableForeign = $oldSchema->createTable('foreign'); $tableA = $oldSchema->createTable('table_a');
$tableForeign->addColumn('id', 'integer'); $tableA->addColumn('id', 'integer');
$tableB = $oldSchema->createTable('table_b');
$tableB->addColumn('id', 'integer');
$table = $oldSchema->createTable('foo'); $tableC = $oldSchema->createTable('table_c');
$table->addColumn('fk', 'integer'); $tableC->addColumn('id', 'integer');
$table->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); $tableC->addColumn('table_a_id', 'integer');
$tableC->addColumn('table_b_id', 'integer');
$tableC->addForeignKeyConstraint($tableA, array('table_a_id'), array('id'));
$tableC->addForeignKeyConstraint($tableB, array('table_b_id'), array('id'));
$newSchema = new Schema(); $newSchema = new Schema();
$table = $newSchema->createTable('foo');
$c = new Comparator(); $tableB = $newSchema->createTable('table_b');
$diff = $c->compare($oldSchema, $newSchema); $tableB->addColumn('id', 'integer');
$tableC = $newSchema->createTable('table_c');
$tableC->addColumn('id', 'integer');
$comparator = new Comparator();
$schemaDiff = $comparator->compare($oldSchema, $newSchema);
$this->assertCount(0, $diff->changedTables['foo']->removedForeignKeys); $this->assertCount(1, $schemaDiff->changedTables['table_c']->removedForeignKeys);
$this->assertCount(1, $diff->orphanedForeignKeys); $this->assertCount(1, $schemaDiff->orphanedForeignKeys);
} }
public function testCompareChangedColumn() public function testCompareChangedColumn()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment