Passed
Push — master ( f8cb44...13b119 )
by Luis
04:20 queued 01:13
created

PhUmlDiagramWithGraphvizAndDotTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 54
loc 54
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_generates_a_class_diagram_using_graphviz_and_dot_processors() 23 23 1
A it_generates_a_class_diagram_using_graphviz_and_dot_processors_using_the_recursive_option() 23 23 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
use Lupka\PHPUnitCompareImages\CompareImagesTrait;
9
use PHPUnit\Framework\TestCase;
10
11 View Code Duplication
class PhUmlDiagramWithGraphvizAndDotTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    use CompareImagesTrait;
14
15
    /** @test */
16
    function it_generates_a_class_diagram_using_graphviz_and_dot_processors()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
    {
18
        $success = <<<MESSAGE
19
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
20
[|] Running... (This may take some time)
21
[|] Parsing class structure
22
[|] Running 'Graphviz' processor
23
[|] Running 'Dot' processor
24
[|] Writing generated data to disk
25
26
MESSAGE;
27
        $diagram = __DIR__ . '/../../tests/.output/graphviz-dot.png';
28
29
        passthru(sprintf(
30
            'php %s %s -graphviz -dot %s',
31
            __DIR__ . '/../../src/app/phuml',
32
            __DIR__ . '/../.code/classes',
33
            $diagram
34
        ));
35
36
        $expectedDiagram = __DIR__ . '/../images/graphviz-dot.png';
37
        $this->expectOutputString($success);
38
        $this->assertImagesSame($expectedDiagram, $diagram);
39
    }
40
41
    /** @test */
42
    function it_generates_a_class_diagram_using_graphviz_and_dot_processors_using_the_recursive_option()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
43
    {
44
        $success = <<<MESSAGE
45
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
46
[|] Running... (This may take some time)
47
[|] Parsing class structure
48
[|] Running 'Graphviz' processor
49
[|] Running 'Dot' processor
50
[|] Writing generated data to disk
51
52
MESSAGE;
53
        $diagram = __DIR__ . '/../../tests/.output/graphviz-dot-recursive.png';
54
55
        passthru(sprintf(
56
            'php %s -r %s -graphviz -dot %s',
57
            __DIR__ . '/../../src/app/phuml',
58
            __DIR__ . '/../.code',
59
            $diagram
60
        ));
61
62
        $expectedDiagram = __DIR__ . '/../images/graphviz-dot-recursive.png';
63
        $this->expectOutputString($success);
64
        $this->assertImagesSame($expectedDiagram, $diagram);
65
    }
66
}
67