Completed
Push — master ( 6a83c2...6c3c1b )
by Alessandro
04:16
created

StubbedPHPUnitBaseTestCase::getOutputFileContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Paraunit\Tests;
4
5
use Paraunit\Tests\Stub\StubbedParaProcess;
6
7
abstract class StubbedPHPUnitBaseTestCase extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @return StubbedParaProcess
11
     */
12
    public function getTestWithSingleError()
13
    {
14
        $process = new StubbedParaProcess();
15
        $process->setExitCode(-1);
16
        $process->setOutput($this->getOutputFileContent('SingleError.txt'));
17
18
        return $process;
19
    }
20
21
    /**
22
     * @return StubbedParaProcess
23
     */
24
    public function getTestWithSingleWarning()
25
    {
26
        $process = new StubbedParaProcess();
27
        $process->setExitCode(-1);
28
        $process->setOutput($this->getOutputFileContent('SingleWarning.txt'));
29
30
        return $process;
31
    }
32
33
    /**
34
     * @return StubbedParaProcess
35
     */
36
    public function getTestWith2Errors2Failures()
37
    {
38
        $process = new StubbedParaProcess();
39
        $process->setExitCode(-1);
40
        $process->setOutput($this->getOutputFileContent('2Errors2Failures.txt'));
41
42
        return $process;
43
    }
44
45
    /**
46
     * @return StubbedParaProcess
47
     */
48
    public function getTestWithParserRegression()
49
    {
50
        $process = new StubbedParaProcess();
51
        $process->setExitCode(-1);
52
        $process->setOutput($this->getOutputFileContent('2Errors2Failures_parser_regression.txt'));
53
54
        return $process;
55
    }
56
57
    /**
58
     * @return StubbedParaProcess
59
     */
60
    public function getTestWithAllGreen()
61
    {
62
        $process = new StubbedParaProcess();
63
        $process->setExitCode(0);
64
        $process->setOutput($this->getOutputFileContent('AllGreen.txt'));
65
66
        return $process;
67
    }
68
69
    /**
70
     * @return StubbedParaProcess
71
     */
72
    public function getTestWithAllGreen5()
73
    {
74
        $process = new StubbedParaProcess();
75
        $process->setExitCode(0);
76
        $process->setOutput($this->getOutputFileContent('AllGreen5.txt'));
77
78
        return $process;
79
    }
80
81
    /**
82
     * @return StubbedParaProcess
83
     */
84
    public function getTestWithFatalError()
85
    {
86
        $process = new StubbedParaProcess();
87
        $process->setExitCode(-1);
88
        $process->setOutput($this->getOutputFileContent('FatalError.txt'));
89
90
        return $process;
91
    }
92
93
    /**
94
     * @return StubbedParaProcess
95
     */
96
    public function getTestWithSegFault()
97
    {
98
        if (!extension_loaded('sigsegv')) {
99
            $this->markTestIncomplete('The segfault cannot be reproduced in this environment');
100
        }
101
102
        $process = new StubbedParaProcess();
103
        $process->setExitCode(-1);
104
        $process->setOutput($this->getOutputFileContent('SegFault.txt'));
105
106
        return $process;
107
    }
108
109
    /**
110
     * @return StubbedParaProcess
111
     */
112
    public function getTestWithVeryLongOutput()
113
    {
114
        $process = new StubbedParaProcess();
115
        $process->setExitCode(0);
116
        $process->setOutput($this->getOutputFileContent('VeryLongOutput.txt'));
117
118
        return $process;
119
    }
120
121
    /**
122
     * @param $filename
123
     *
124
     * @return string
125
     */
126
    protected function getOutputFileContent($filename)
127
    {
128
        return file_get_contents(__DIR__.'/Stub/PHPUnitOutput/'.$filename);
129
    }
130
}
131