Code Duplication    Length = 25-25 lines in 3 locations

tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php 3 locations

@@ 641-665 (lines=25) @@
638
     /**
639
     * @group DDC-2172
640
     */
641
    public function testGetInheritanceTypeString()
642
    {
643
        $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo');
644
        $method     = new \ReflectionMethod($this->_generator, 'getInheritanceTypeString');
645
        $constants  = $reflection->getConstants();
646
        $pattern    = '/^INHERITANCE_TYPE_/';
647
648
        $method->setAccessible(true);
649
650
        foreach ($constants as $name => $value) {
651
            if( ! preg_match($pattern, $name)) {
652
                continue;
653
            }
654
655
            $expected = preg_replace($pattern, '', $name);
656
            $actual   = $method->invoke($this->_generator, $value);
657
658
            $this->assertEquals($expected, $actual);
659
        }
660
661
        $this->expectException(\InvalidArgumentException::class);
662
        $this->expectExceptionMessage('Invalid provided InheritanceType: INVALID');
663
664
        $method->invoke($this->_generator, 'INVALID');
665
    }
666
667
    /**
668
    * @group DDC-2172
@@ 670-694 (lines=25) @@
667
    /**
668
    * @group DDC-2172
669
    */
670
    public function testGetChangeTrackingPolicyString()
671
    {
672
        $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
673
        $method     = new \ReflectionMethod($this->_generator, 'getChangeTrackingPolicyString');
674
        $constants  = $reflection->getConstants();
675
        $pattern    = '/^CHANGETRACKING_/';
676
677
        $method->setAccessible(true);
678
679
        foreach ($constants as $name => $value) {
680
            if( ! preg_match($pattern, $name)) {
681
                continue;
682
            }
683
684
            $expected = preg_replace($pattern, '', $name);
685
            $actual   = $method->invoke($this->_generator, $value);
686
687
            $this->assertEquals($expected, $actual);
688
        }
689
690
        $this->expectException(\InvalidArgumentException::class);
691
        $this->expectExceptionMessage('Invalid provided ChangeTrackingPolicy: INVALID');
692
693
        $method->invoke($this->_generator, 'INVALID');
694
    }
695
696
    /**
697
     * @group DDC-2172
@@ 699-723 (lines=25) @@
696
    /**
697
     * @group DDC-2172
698
     */
699
    public function testGetIdGeneratorTypeString()
700
    {
701
        $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadataInfo');
702
        $method     = new \ReflectionMethod($this->_generator, 'getIdGeneratorTypeString');
703
        $constants  = $reflection->getConstants();
704
        $pattern    = '/^GENERATOR_TYPE_/';
705
706
        $method->setAccessible(true);
707
708
        foreach ($constants as $name => $value) {
709
            if( ! preg_match($pattern, $name)) {
710
                continue;
711
            }
712
713
            $expected = preg_replace($pattern, '', $name);
714
            $actual   = $method->invoke($this->_generator, $value);
715
716
            $this->assertEquals($expected, $actual);
717
        }
718
719
        $this->expectException(\InvalidArgumentException::class);
720
        $this->expectExceptionMessage('Invalid provided IdGeneratorType: INVALID');
721
722
        $method->invoke($this->_generator, 'INVALID');
723
    }
724
725
    /**
726
     * @dataProvider getEntityTypeAliasDataProvider