Code Duplication    Length = 30-32 lines in 2 locations

src/Oro/Bundle/TestGeneratorBundle/Generator/EntityTestGenerator.php 1 location

@@ 15-46 (lines=32) @@
12
    /**
13
     * @param string $className
14
     */
15
    public function generate($className)
16
    {
17
        $this->className = $className;
18
        $class = new \ReflectionClass($className);
19
        $propertiesData = $this->getProperties($class);
20
        $fullTestNameSpace = $this->getNamespaceForTest($className, 'unit');
21
        $parts = explode('\\', $fullTestNameSpace);
22
        $testClassName = array_pop($parts);
23
        $partsOfOriginClass = explode('\\', $className);
24
        $testedClassName = array_pop($partsOfOriginClass);
25
        $nameSpace = implode('\\', $parts);
26
        $testPath = $this->getTestPath($fullTestNameSpace);
27
        $constructor = $class->getConstructor();
28
        $dependencies = $constructor ? $this->getDependencies($constructor) : [];
29
        $dependenciesData = $this->getDependenciesData($dependencies);
30
        $this->addClassToUses($className);
31
        $this->addClassToUses('Oro\Component\Testing\Unit\EntityTestCaseTrait');
32
        $orderedUses = $this->getOrderedUses($this->usedClasses);
33
        $content = $this->twig->render(
34
            '@OroTestGenerator/Tests/entity_template.php.twig',
35
            [
36
                'namespace' => $nameSpace,
37
                'vendors' => $orderedUses,
38
                'className' => $testClassName,
39
                'testedClassName' => $testedClassName,
40
                'testedClassNameVariable' => lcfirst($testedClassName),
41
                'dependenciesData' => $dependenciesData,
42
                'propertiesData' => $propertiesData
43
            ]
44
        );
45
        $this->createFile($testPath, $content);
46
    }
47
48
    /**
49
     * @param \ReflectionClass $class

src/Oro/Bundle/TestGeneratorBundle/Generator/UnitTestGenerator.php 1 location

@@ 10-39 (lines=30) @@
7
    /**
8
     * @param string $className
9
     */
10
    public function generate($className)
11
    {
12
        $fullTestNameSpace = $this->getNamespaceForTest($className, 'unit');
13
        $parts = explode('\\', $fullTestNameSpace);
14
        $testClassName = array_pop($parts);
15
        $partsOfOriginClass = explode('\\', $className);
16
        $testedClassName = array_pop($partsOfOriginClass);
17
        $nameSpace = implode('\\', $parts);
18
        $testPath = $this->getTestPath($fullTestNameSpace);
19
        $class = new \ReflectionClass($className);
20
        $constructor = $class->getConstructor();
21
        $dependencies = $constructor ? $this->getDependencies($constructor) : [];
22
        $dependenciesData = $this->getDependenciesData($dependencies);
23
        $methodsData = $this->getMethodsData($class);
24
        $this->addClassToUses($className);
25
        $orderedUses = $this->getOrderedUses($this->usedClasses);
26
        $content = $this->twig->render(
27
            '@OroTestGenerator/Tests/unit_template.php.twig',
28
            [
29
                'namespace' => $nameSpace,
30
                'vendors' => $orderedUses,
31
                'className' => $testClassName,
32
                'testedClassName' => $testedClassName,
33
                'testedClassNameVariable' => lcfirst($testedClassName),
34
                'dependenciesData' => $dependenciesData,
35
                'methodsData' => $methodsData
36
            ]
37
        );
38
        $this->createFile($testPath, $content);
39
    }
40
}
41