Code Duplication    Length = 25-25 lines in 3 locations

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

@@ 775-799 (lines=25) @@
772
     /**
773
     * @group DDC-2172
774
     */
775
    public function testGetInheritanceTypeString()
776
    {
777
        $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
778
        $method     = new \ReflectionMethod($this->generator, 'getInheritanceTypeString');
779
        $constants  = $reflection->getConstants();
780
        $pattern    = '/^InheritanceType::/';
781
782
        $method->setAccessible(true);
783
784
        foreach ($constants as $name => $value) {
785
            if( ! preg_match($pattern, $name)) {
786
                continue;
787
            }
788
789
            $expected = preg_replace($pattern, '', $name);
790
            $actual   = $method->invoke($this->generator, $value);
791
792
            self::assertEquals($expected, $actual);
793
        }
794
795
        $this->expectException(\InvalidArgumentException::class);
796
        $this->expectExceptionMessage('Invalid provided InheritanceType: INVALID');
797
798
        $method->invoke($this->generator, 'INVALID');
799
    }
800
801
    /**
802
    * @group DDC-2172
@@ 804-828 (lines=25) @@
801
    /**
802
    * @group DDC-2172
803
    */
804
    public function testGetChangeTrackingPolicyString()
805
    {
806
        $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
807
        $method     = new \ReflectionMethod($this->generator, 'getChangeTrackingPolicyString');
808
        $constants  = $reflection->getConstants();
809
        $pattern    = '/^ChangeTrackingPolicy::/';
810
811
        $method->setAccessible(true);
812
813
        foreach ($constants as $name => $value) {
814
            if( ! preg_match($pattern, $name)) {
815
                continue;
816
            }
817
818
            $expected = preg_replace($pattern, '', $name);
819
            $actual   = $method->invoke($this->generator, $value);
820
821
            self::assertEquals($expected, $actual);
822
        }
823
824
        $this->expectException(\InvalidArgumentException::class);
825
        $this->expectExceptionMessage('Invalid provided ChangeTrackingPolicy: INVALID');
826
827
        $method->invoke($this->generator, 'INVALID');
828
    }
829
830
    /**
831
     * @group DDC-2172
@@ 833-857 (lines=25) @@
830
    /**
831
     * @group DDC-2172
832
     */
833
    public function testGetIdGeneratorTypeString()
834
    {
835
        $reflection = new \ReflectionClass('\Doctrine\ORM\Mapping\ClassMetadata');
836
        $method     = new \ReflectionMethod($this->generator, 'getIdGeneratorTypeString');
837
        $constants  = $reflection->getConstants();
838
        $pattern    = '/^GeneratorType::/';
839
840
        $method->setAccessible(true);
841
842
        foreach ($constants as $name => $value) {
843
            if( ! preg_match($pattern, $name)) {
844
                continue;
845
            }
846
847
            $expected = preg_replace($pattern, '', $name);
848
            $actual   = $method->invoke($this->generator, $value);
849
850
            self::assertEquals($expected, $actual);
851
        }
852
853
        $this->expectException(\InvalidArgumentException::class);
854
        $this->expectExceptionMessage('Invalid provided IdGeneratorType: INVALID');
855
856
        $method->invoke($this->generator, 'INVALID');
857
    }
858
859
    /**
860
     * @dataProvider getEntityTypeAliasDataProvider