Completed
Push — output_parsers_refactor ( 9ffc6c...755930 )
by Alessandro
09:57
created

BaseFunctionalTestCase   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 134
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 12
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 134
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A getTestWithSingleError() 0 8 1
A getTestWithSingleWarning() 0 8 1
A getTestWith2Errors2Failures() 0 8 1
A getTestWithParserRegression() 0 8 1
A getTestWithAllGreen() 0 8 1
A getTestWithAllGreen5() 0 8 1
A getTestWithFatalError() 0 8 1
A getTestWithSegFault() 0 12 2
A getTestWithVeryLongOutput() 0 8 1
A getOutputFileContent() 0 4 1
1
<?php
2
3
namespace Paraunit\Tests;
4
5
use Paraunit\Configuration\Paraunit;
6
use Paraunit\Tests\Stub\StubbedParaProcess;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
9
/**
10
 * Class BaseFunctionalTestCase
11
 * @package Paraunit\Tests
12
 */
13
abstract class BaseFunctionalTestCase extends \PHPUnit_Framework_TestCase
14
{
15
    /** @var ContainerBuilder */
16
    protected $container = null;
17
18
    public function setUp()
19
    {
20
        parent::setUp();
21
22
        $this->container = Paraunit::buildContainer();
23
    }
24
25
    /**
26
     * @return StubbedParaProcess
27
     */
28
    public function getTestWithSingleError()
29
    {
30
        $process = new StubbedParaProcess();
31
        $process->setExitCode(-1);
32
        $process->setOutput($this->getOutputFileContent('SingleError.txt'));
33
34
        return $process;
35
    }
36
37
    /**
38
     * @return StubbedParaProcess
39
     */
40
    public function getTestWithSingleWarning()
41
    {
42
        $process = new StubbedParaProcess();
43
        $process->setExitCode(-1);
44
        $process->setOutput($this->getOutputFileContent('SingleWarning.txt'));
45
46
        return $process;
47
    }
48
49
    /**
50
     * @return StubbedParaProcess
51
     */
52
    public function getTestWith2Errors2Failures()
53
    {
54
        $process = new StubbedParaProcess();
55
        $process->setExitCode(-1);
56
        $process->setOutput($this->getOutputFileContent('2Errors2Failures.txt'));
57
58
        return $process;
59
    }
60
61
    /**
62
     * @return StubbedParaProcess
63
     */
64
    public function getTestWithParserRegression()
65
    {
66
        $process = new StubbedParaProcess();
67
        $process->setExitCode(-1);
68
        $process->setOutput($this->getOutputFileContent('2Errors2Failures_parser_regression.txt'));
69
70
        return $process;
71
    }
72
73
    /**
74
     * @return StubbedParaProcess
75
     */
76
    public function getTestWithAllGreen()
77
    {
78
        $process = new StubbedParaProcess();
79
        $process->setExitCode(0);
80
        $process->setOutput($this->getOutputFileContent('AllGreen.txt'));
81
82
        return $process;
83
    }
84
85
    /**
86
     * @return StubbedParaProcess
87
     */
88
    public function getTestWithAllGreen5()
89
    {
90
        $process = new StubbedParaProcess();
91
        $process->setExitCode(0);
92
        $process->setOutput($this->getOutputFileContent('AllGreen5.txt'));
93
94
        return $process;
95
    }
96
97
    /**
98
     * @return StubbedParaProcess
99
     */
100
    public function getTestWithFatalError()
101
    {
102
        $process = new StubbedParaProcess();
103
        $process->setExitCode(-1);
104
        $process->setOutput($this->getOutputFileContent('FatalError.txt'));
105
106
        return $process;
107
    }
108
109
    /**
110
     * @return StubbedParaProcess
111
     */
112
    public function getTestWithSegFault()
113
    {
114
        if ( ! extension_loaded('sigsegv')) {
115
            $this->markTestIncomplete('The segfault cannot be reproduced in this environment');
116
        }
117
118
        $process = new StubbedParaProcess();
119
        $process->setExitCode(-1);
120
        $process->setOutput($this->getOutputFileContent('SegFault.txt'));
121
122
        return $process;
123
    }
124
125
    /**
126
     * @return StubbedParaProcess
127
     */
128
    public function getTestWithVeryLongOutput()
129
    {
130
        $process = new StubbedParaProcess();
131
        $process->setExitCode(0);
132
        $process->setOutput($this->getOutputFileContent('VeryLongOutput.txt'));
133
134
        return $process;
135
    }
136
137
    /**
138
     * @param $filename
139
     *
140
     * @return string
141
     */
142
    protected function getOutputFileContent($filename)
143
    {
144
        return file_get_contents(__DIR__ . '/Stub/PHPUnitOutput/' . $filename);
145
    }
146
}
147