|
@@ 472-489 (lines=18) @@
|
| 469 |
|
self::assertSame($seq, $diffSchema->newSequences[0]); |
| 470 |
|
} |
| 471 |
|
|
| 472 |
|
public function testTableAddForeignKey() |
| 473 |
|
{ |
| 474 |
|
$tableForeign = new Table("bar"); |
| 475 |
|
$tableForeign->addColumn('id', 'integer'); |
| 476 |
|
|
| 477 |
|
$table1 = new Table("foo"); |
| 478 |
|
$table1->addColumn('fk', 'integer'); |
| 479 |
|
|
| 480 |
|
$table2 = new Table("foo"); |
| 481 |
|
$table2->addColumn('fk', 'integer'); |
| 482 |
|
$table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); |
| 483 |
|
|
| 484 |
|
$c = new Comparator(); |
| 485 |
|
$tableDiff = $c->diffTable($table1, $table2); |
| 486 |
|
|
| 487 |
|
self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); |
| 488 |
|
self::assertCount(1, $tableDiff->addedForeignKeys); |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
public function testTableRemoveForeignKey() |
| 492 |
|
{ |
|
@@ 491-508 (lines=18) @@
|
| 488 |
|
self::assertCount(1, $tableDiff->addedForeignKeys); |
| 489 |
|
} |
| 490 |
|
|
| 491 |
|
public function testTableRemoveForeignKey() |
| 492 |
|
{ |
| 493 |
|
$tableForeign = new Table("bar"); |
| 494 |
|
$tableForeign->addColumn('id', 'integer'); |
| 495 |
|
|
| 496 |
|
$table1 = new Table("foo"); |
| 497 |
|
$table1->addColumn('fk', 'integer'); |
| 498 |
|
|
| 499 |
|
$table2 = new Table("foo"); |
| 500 |
|
$table2->addColumn('fk', 'integer'); |
| 501 |
|
$table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id')); |
| 502 |
|
|
| 503 |
|
$c = new Comparator(); |
| 504 |
|
$tableDiff = $c->diffTable($table2, $table1); |
| 505 |
|
|
| 506 |
|
self::assertInstanceOf('Doctrine\DBAL\Schema\TableDiff', $tableDiff); |
| 507 |
|
self::assertCount(1, $tableDiff->removedForeignKeys); |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
public function testTableUpdateForeignKey() |
| 511 |
|
{ |
|
@@ 627-646 (lines=20) @@
|
| 624 |
|
self::assertFalse($tableDiff); |
| 625 |
|
} |
| 626 |
|
|
| 627 |
|
public function testCompareIndexBasedOnPropertiesNotName() |
| 628 |
|
{ |
| 629 |
|
$tableA = new Table("foo"); |
| 630 |
|
$tableA->addColumn('id', 'integer'); |
| 631 |
|
$tableA->addIndex(array("id"), "foo_bar_idx"); |
| 632 |
|
|
| 633 |
|
$tableB = new Table("foo"); |
| 634 |
|
$tableB->addColumn('ID', 'integer'); |
| 635 |
|
$tableB->addIndex(array("id"), "bar_foo_idx"); |
| 636 |
|
|
| 637 |
|
$c = new Comparator(); |
| 638 |
|
$tableDiff = new TableDiff('foo'); |
| 639 |
|
$tableDiff->fromTable = $tableA; |
| 640 |
|
$tableDiff->renamedIndexes['foo_bar_idx'] = new Index('bar_foo_idx', array('id')); |
| 641 |
|
|
| 642 |
|
self::assertEquals( |
| 643 |
|
$tableDiff, |
| 644 |
|
$c->diffTable($tableA, $tableB) |
| 645 |
|
); |
| 646 |
|
} |
| 647 |
|
|
| 648 |
|
public function testCompareForeignKeyBasedOnPropertiesNotName() |
| 649 |
|
{ |