Test Failed
Push — graphviz-refactoring ( 3f1b14 )
by Luis
02:18
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

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
    function it_does_not_allow_dot_and_neato_as_initial_processors($firstProcessor, $secondProcessor)
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()
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
    function it_does_not_allow_statistics_as_initial_processor($firstProcessor, $secondProcessor)
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()
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()
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