Code Duplication    Length = 22-30 lines in 4 locations

Tests/DependencyInjection/DoctrineExtensionTest.php 4 locations

@@ 505-526 (lines=22) @@
502
        $this->assertEquals('YamlBundle\Cache\MyCacheFactory', $slcDefinition->getClass());
503
    }
504
505
    public function testBundleEntityAliases() : void
506
    {
507
        if (! interface_exists(EntityManagerInterface::class)) {
508
            self::markTestSkipped('This test requires ORM');
509
        }
510
511
        $container = $this->getContainer();
512
        $extension = new DoctrineExtension();
513
514
        $config        = BundleConfigurationBuilder::createBuilder()
515
             ->addBaseConnection()
516
             ->build();
517
        $config['orm'] = ['default_entity_manager' => 'default', 'entity_managers' => ['default' => ['mappings' => ['YamlBundle' => []]]]];
518
        $extension->load([$config], $container);
519
520
        $definition = $container->getDefinition('doctrine.orm.default_configuration');
521
        $this->assertDICDefinitionMethodCallOnce(
522
            $definition,
523
            'setEntityNamespaces',
524
            [['YamlBundle' => 'Fixtures\Bundles\YamlBundle\Entity']]
525
        );
526
    }
527
528
    public function testOverwriteEntityAliases() : void
529
    {
@@ 528-549 (lines=22) @@
525
        );
526
    }
527
528
    public function testOverwriteEntityAliases() : void
529
    {
530
        if (! interface_exists(EntityManagerInterface::class)) {
531
            self::markTestSkipped('This test requires ORM');
532
        }
533
534
        $container = $this->getContainer();
535
        $extension = new DoctrineExtension();
536
537
        $config        = BundleConfigurationBuilder::createBuilder()
538
             ->addBaseConnection()
539
             ->build();
540
        $config['orm'] = ['default_entity_manager' => 'default', 'entity_managers' => ['default' => ['mappings' => ['YamlBundle' => ['alias' => 'yml']]]]];
541
        $extension->load([$config], $container);
542
543
        $definition = $container->getDefinition('doctrine.orm.default_configuration');
544
        $this->assertDICDefinitionMethodCallOnce(
545
            $definition,
546
            'setEntityNamespaces',
547
            [['yml' => 'Fixtures\Bundles\YamlBundle\Entity']]
548
        );
549
    }
550
551
    public function testYamlBundleMappingDetection() : void
552
    {
@@ 573-602 (lines=30) @@
570
        ]);
571
    }
572
573
    public function testXmlBundleMappingDetection() : void
574
    {
575
        if (! interface_exists(EntityManagerInterface::class)) {
576
            self::markTestSkipped('This test requires ORM');
577
        }
578
579
        $container = $this->getContainer('XmlBundle');
580
        $extension = new DoctrineExtension();
581
582
        $config = BundleConfigurationBuilder::createBuilder()
583
            ->addBaseConnection()
584
            ->addEntityManager([
585
                'default_entity_manager' => 'default',
586
                'entity_managers' => [
587
                    'default' => [
588
                        'mappings' => [
589
                            'XmlBundle' => [],
590
                        ],
591
                    ],
592
                ],
593
            ])
594
            ->build();
595
        $extension->load([$config], $container);
596
597
        $definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
598
        $this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', [
599
            new Reference('doctrine.orm.default_xml_metadata_driver'),
600
            'Fixtures\Bundles\XmlBundle\Entity',
601
        ]);
602
    }
603
604
    public function testAnnotationsBundleMappingDetection() : void
605
    {
@@ 604-633 (lines=30) @@
601
        ]);
602
    }
603
604
    public function testAnnotationsBundleMappingDetection() : void
605
    {
606
        if (! interface_exists(EntityManagerInterface::class)) {
607
            self::markTestSkipped('This test requires ORM');
608
        }
609
610
        $container = $this->getContainer('AnnotationsBundle');
611
        $extension = new DoctrineExtension();
612
613
        $config = BundleConfigurationBuilder::createBuilder()
614
            ->addBaseConnection()
615
            ->addEntityManager([
616
                'default_entity_manager' => 'default',
617
                'entity_managers' => [
618
                    'default' => [
619
                        'mappings' => [
620
                            'AnnotationsBundle' => [],
621
                        ],
622
                    ],
623
                ],
624
            ])
625
            ->build();
626
        $extension->load([$config], $container);
627
628
        $definition = $container->getDefinition('doctrine.orm.default_metadata_driver');
629
        $this->assertDICDefinitionMethodCallOnce($definition, 'addDriver', [
630
            new Reference('doctrine.orm.default_annotation_metadata_driver'),
631
            'Fixtures\Bundles\AnnotationsBundle\Entity',
632
        ]);
633
    }
634
635
    public function testOrmMergeConfigs() : void
636
    {