Code Duplication    Length = 15-16 lines in 4 locations

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

@@ 393-407 (lines=15) @@
390
    /**
391
     * @group DBAL-1063
392
     */
393
    public function testAddForeignKeyDoesNotCreateDuplicateIndex() : void
394
    {
395
        $table = new Table('foo');
396
        $table->addColumn('bar', 'integer');
397
        $table->addIndex(['bar'], 'bar_idx');
398
399
        $foreignTable = new Table('bar');
400
        $foreignTable->addColumn('foo', 'integer');
401
402
        $table->addForeignKeyConstraint($foreignTable, ['bar'], ['foo']);
403
404
        self::assertCount(1, $table->getIndexes());
405
        self::assertTrue($table->hasIndex('bar_idx'));
406
        self::assertSame(['bar'], $table->getIndex('bar_idx')->getColumns());
407
    }
408
409
    /**
410
     * @group DBAL-1063
@@ 509-524 (lines=16) @@
506
        self::assertTrue($table->hasIndex('idx_unique'));
507
    }
508
509
    public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex() : void
510
    {
511
        $foreignTable = new Table('foreign');
512
        $foreignTable->addColumn('id', 'integer');
513
514
        $localTable = new Table('local');
515
        $localTable->addColumn('id', 'integer');
516
        $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
517
518
        self::assertCount(1, $localTable->getIndexes());
519
520
        $localTable->addIndex(['id'], 'explicit_idx');
521
522
        self::assertCount(1, $localTable->getIndexes());
523
        self::assertTrue($localTable->hasIndex('explicit_idx'));
524
    }
525
526
    public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex() : void
527
    {
@@ 526-541 (lines=16) @@
523
        self::assertTrue($localTable->hasIndex('explicit_idx'));
524
    }
525
526
    public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex() : void
527
    {
528
        $foreignTable = new Table('foreign');
529
        $foreignTable->addColumn('id', 'integer');
530
531
        $localTable = new Table('local');
532
        $localTable->addColumn('id', 'integer');
533
        $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
534
535
        self::assertCount(1, $localTable->getIndexes());
536
537
        $localTable->addUniqueIndex(['id'], 'explicit_idx');
538
539
        self::assertCount(1, $localTable->getIndexes());
540
        self::assertTrue($localTable->hasIndex('explicit_idx'));
541
    }
542
543
    public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex() : void
544
    {
@@ 543-558 (lines=16) @@
540
        self::assertTrue($localTable->hasIndex('explicit_idx'));
541
    }
542
543
    public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex() : void
544
    {
545
        $foreignTable = new Table('foreign');
546
        $foreignTable->addColumn('id', 'integer');
547
548
        $localTable = new Table('local');
549
        $localTable->addColumn('id', 'integer');
550
        $localTable->addForeignKeyConstraint($foreignTable, ['id'], ['id']);
551
552
        self::assertCount(1, $localTable->getIndexes());
553
554
        $localTable->setPrimaryKey(['id'], 'explicit_idx');
555
556
        self::assertCount(1, $localTable->getIndexes());
557
        self::assertTrue($localTable->hasIndex('explicit_idx'));
558
    }
559
560
    public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException() : void
561
    {