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

PhUmlIncompatibleProcessorsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 87
Duplicated Lines 43.68 %

Importance

Changes 0
Metric Value
dl 38
loc 87
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_does_not_allow_statistics_and_graphviz_combination() 0 16 1
A it_does_not_allow_statistics_as_initial_processor() 18 18 1
A incompatibleDotAndNeatoCombinations() 0 9 1
A incompatibleStatisticsCombinations() 0 5 1
A it_does_not_allow_dot_and_neato_as_initial_processors() 18 18 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 PHPUnit\Framework\TestCase;
9
10
class PhUmlIncompatibleProcessorsTest extends TestCase
11
{
12
    /**
13
     * @test
14
     * @dataProvider incompatibleDotAndNeatoCombinations
15
     */
16 View Code Duplication
    function it_does_not_allow_dot_and_neato_as_initial_processors($firstProcessor, $secondProcessor)
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...
Duplication introduced by
This method 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...
17
    {
18
        $incompatibleProcessors = <<<MESSAGE
19
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
20
A fatal error occured during the process:
21
To processors in the chain are incompatible. The first processor's output is "application/phuml-structure". The next Processor in the queue does only support the following input types: text/dot.
22
23
MESSAGE;
24
25
        passthru(sprintf(
26
            'php %s %s -%s -%s willnotbecreated.png',
27
            __DIR__ . '/../../src/app/phuml',
28
            __DIR__ . '/../../src',
29
            $firstProcessor,
30
            $secondProcessor
31
        ));
32
33
        $this->expectOutputString($incompatibleProcessors);
34
    }
35
36
    function incompatibleDotAndNeatoCombinations()
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...
37
    {
38
        return [
39
            'dot -> neato' => ['dot', 'neato'],
40
            'dot -> statistics' => ['dot', 'statistics'],
41
            'dot -> graphviz' => ['dot', 'graphviz'],
42
            'neato -> dot' => ['neato', 'dot'],
43
            'neato -> statistics' => ['neato', 'statistics'],
44
            'neato -> graphviz' => ['dot', 'graphviz'],
45
        ];
46
    }
47
48
    /**
49
     * @test
50
     * @dataProvider incompatibleStatisticsCombinations
51
     */
52 View Code Duplication
    function it_does_not_allow_statistics_as_initial_processor($firstProcessor, $secondProcessor)
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...
Duplication introduced by
This method 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...
53
    {
54
        $incompatibleProcessors = <<<MESSAGE
55
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
56
A fatal error occured during the process:
57
To processors in the chain are incompatible. The first processor's output is "text/plain". The next Processor in the queue does only support the following input types: text/dot.
58
59
MESSAGE;
60
61
        passthru(sprintf(
62
            'php %s %s -%s -%s willnotbecreated.png',
63
            __DIR__ . '/../../src/app/phuml',
64
            __DIR__ . '/../../src',
65
            $firstProcessor,
66
            $secondProcessor
67
        ));
68
69
        $this->expectOutputString($incompatibleProcessors);
70
    }
71
72
    function incompatibleStatisticsCombinations()
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...
73
    {
74
        return [
75
            'statistics -> neato' => ['statistics', 'dot'],
76
            'statistics -> dot' => ['statistics', 'neato'],
77
        ];
78
    }
79
80
    /** @test */
81
    function it_does_not_allow_statistics_and_graphviz_combination()
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...
82
    {
83
        $incompatibleProcessors = <<<MESSAGE
84
phUML Version 0.2 (Jakob Westhoff <[email protected]>)
85
A fatal error occured during the process:
86
To processors in the chain are incompatible. The first processor's output is "text/plain". The next Processor in the queue does only support the following input types: application/phuml-structure.
87
88
MESSAGE;
89
90
        passthru(sprintf(
91
            'php %s %s -statistics -graphviz willnotbecreated.png',
92
            __DIR__ . '/../../src/app/phuml',
93
            __DIR__ . '/../../src'
94
        ));
95
96
        $this->expectOutputString($incompatibleProcessors);
97
    }
98
}
99