|
@@ 378-392 (lines=15) @@
|
| 375 |
|
/** |
| 376 |
|
* @group DBAL-1063 |
| 377 |
|
*/ |
| 378 |
|
public function testAddForeignKeyDoesNotCreateDuplicateIndex() |
| 379 |
|
{ |
| 380 |
|
$table = new Table('foo'); |
| 381 |
|
$table->addColumn('bar', 'integer'); |
| 382 |
|
$table->addIndex(array('bar'), 'bar_idx'); |
| 383 |
|
|
| 384 |
|
$foreignTable = new Table('bar'); |
| 385 |
|
$foreignTable->addColumn('foo', 'integer'); |
| 386 |
|
|
| 387 |
|
$table->addForeignKeyConstraint($foreignTable, array('bar'), array('foo')); |
| 388 |
|
|
| 389 |
|
$this->assertCount(1, $table->getIndexes()); |
| 390 |
|
$this->assertTrue($table->hasIndex('bar_idx')); |
| 391 |
|
$this->assertSame(array('bar'), $table->getIndex('bar_idx')->getColumns()); |
| 392 |
|
} |
| 393 |
|
|
| 394 |
|
/** |
| 395 |
|
* @group DBAL-1063 |
|
@@ 548-563 (lines=16) @@
|
| 545 |
|
self::assertTrue($table->hasIndex('idx_unique')); |
| 546 |
|
} |
| 547 |
|
|
| 548 |
|
public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex() |
| 549 |
|
{ |
| 550 |
|
$foreignTable = new Table('foreign'); |
| 551 |
|
$foreignTable->addColumn('id', 'integer'); |
| 552 |
|
|
| 553 |
|
$localTable = new Table('local'); |
| 554 |
|
$localTable->addColumn('id', 'integer'); |
| 555 |
|
$localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id')); |
| 556 |
|
|
| 557 |
|
$this->assertCount(1, $localTable->getIndexes()); |
| 558 |
|
|
| 559 |
|
$localTable->addIndex(array('id'), 'explicit_idx'); |
| 560 |
|
|
| 561 |
|
$this->assertCount(1, $localTable->getIndexes()); |
| 562 |
|
$this->assertTrue($localTable->hasIndex('explicit_idx')); |
| 563 |
|
} |
| 564 |
|
|
| 565 |
|
public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex() |
| 566 |
|
{ |
|
@@ 565-580 (lines=16) @@
|
| 562 |
|
$this->assertTrue($localTable->hasIndex('explicit_idx')); |
| 563 |
|
} |
| 564 |
|
|
| 565 |
|
public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex() |
| 566 |
|
{ |
| 567 |
|
$foreignTable = new Table('foreign'); |
| 568 |
|
$foreignTable->addColumn('id', 'integer'); |
| 569 |
|
|
| 570 |
|
$localTable = new Table('local'); |
| 571 |
|
$localTable->addColumn('id', 'integer'); |
| 572 |
|
$localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id')); |
| 573 |
|
|
| 574 |
|
$this->assertCount(1, $localTable->getIndexes()); |
| 575 |
|
|
| 576 |
|
$localTable->addUniqueIndex(array('id'), 'explicit_idx'); |
| 577 |
|
|
| 578 |
|
$this->assertCount(1, $localTable->getIndexes()); |
| 579 |
|
$this->assertTrue($localTable->hasIndex('explicit_idx')); |
| 580 |
|
} |
| 581 |
|
|
| 582 |
|
public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex() |
| 583 |
|
{ |
|
@@ 582-597 (lines=16) @@
|
| 579 |
|
$this->assertTrue($localTable->hasIndex('explicit_idx')); |
| 580 |
|
} |
| 581 |
|
|
| 582 |
|
public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex() |
| 583 |
|
{ |
| 584 |
|
$foreignTable = new Table('foreign'); |
| 585 |
|
$foreignTable->addColumn('id', 'integer'); |
| 586 |
|
|
| 587 |
|
$localTable = new Table('local'); |
| 588 |
|
$localTable->addColumn('id', 'integer'); |
| 589 |
|
$localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id')); |
| 590 |
|
|
| 591 |
|
$this->assertCount(1, $localTable->getIndexes()); |
| 592 |
|
|
| 593 |
|
$localTable->setPrimaryKey(array('id'), 'explicit_idx'); |
| 594 |
|
|
| 595 |
|
$this->assertCount(1, $localTable->getIndexes()); |
| 596 |
|
$this->assertTrue($localTable->hasIndex('explicit_idx')); |
| 597 |
|
} |
| 598 |
|
|
| 599 |
|
public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException() |
| 600 |
|
{ |