Code Duplication    Length = 15-16 lines in 4 locations

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

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