Code Duplication    Length = 15-16 lines in 4 locations

tests/Doctrine/Tests/DBAL/Schema/TableTest.php 4 locations

@@ 380-394 (lines=15) @@
377
    /**
378
     * @group DBAL-1063
379
     */
380
    public function testAddForeignKeyDoesNotCreateDuplicateIndex()
381
    {
382
        $table = new Table('foo');
383
        $table->addColumn('bar', 'integer');
384
        $table->addIndex(array('bar'), 'bar_idx');
385
386
        $foreignTable = new Table('bar');
387
        $foreignTable->addColumn('foo', 'integer');
388
389
        $table->addForeignKeyConstraint($foreignTable, array('bar'), array('foo'));
390
391
        self::assertCount(1, $table->getIndexes());
392
        self::assertTrue($table->hasIndex('bar_idx'));
393
        self::assertSame(array('bar'), $table->getIndex('bar_idx')->getColumns());
394
    }
395
396
    /**
397
     * @group DBAL-1063
@@ 496-511 (lines=16) @@
493
        self::assertTrue($table->hasIndex('idx_unique'));
494
    }
495
496
    public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex()
497
    {
498
        $foreignTable = new Table('foreign');
499
        $foreignTable->addColumn('id', 'integer');
500
501
        $localTable = new Table('local');
502
        $localTable->addColumn('id', 'integer');
503
        $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
504
505
        self::assertCount(1, $localTable->getIndexes());
506
507
        $localTable->addIndex(array('id'), 'explicit_idx');
508
509
        self::assertCount(1, $localTable->getIndexes());
510
        self::assertTrue($localTable->hasIndex('explicit_idx'));
511
    }
512
513
    public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex()
514
    {
@@ 513-528 (lines=16) @@
510
        self::assertTrue($localTable->hasIndex('explicit_idx'));
511
    }
512
513
    public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex()
514
    {
515
        $foreignTable = new Table('foreign');
516
        $foreignTable->addColumn('id', 'integer');
517
518
        $localTable = new Table('local');
519
        $localTable->addColumn('id', 'integer');
520
        $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
521
522
        self::assertCount(1, $localTable->getIndexes());
523
524
        $localTable->addUniqueIndex(array('id'), 'explicit_idx');
525
526
        self::assertCount(1, $localTable->getIndexes());
527
        self::assertTrue($localTable->hasIndex('explicit_idx'));
528
    }
529
530
    public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex()
531
    {
@@ 530-545 (lines=16) @@
527
        self::assertTrue($localTable->hasIndex('explicit_idx'));
528
    }
529
530
    public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex()
531
    {
532
        $foreignTable = new Table('foreign');
533
        $foreignTable->addColumn('id', 'integer');
534
535
        $localTable = new Table('local');
536
        $localTable->addColumn('id', 'integer');
537
        $localTable->addForeignKeyConstraint($foreignTable, array('id'), array('id'));
538
539
        self::assertCount(1, $localTable->getIndexes());
540
541
        $localTable->setPrimaryKey(array('id'), 'explicit_idx');
542
543
        self::assertCount(1, $localTable->getIndexes());
544
        self::assertTrue($localTable->hasIndex('explicit_idx'));
545
    }
546
547
    public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException()
548
    {