|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Tests\Unit\TestResult; |
|
6
|
|
|
|
|
7
|
|
|
use Paraunit\TestResult\TestResultContainer; |
|
8
|
|
|
use Paraunit\TestResult\TestResultFormat; |
|
9
|
|
|
use Paraunit\TestResult\TestResultWithAbnormalTermination; |
|
10
|
|
|
use Tests\BaseUnitTestCase; |
|
11
|
|
|
use Tests\Stub\StubbedParaunitProcess; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class TestResultContainerTest |
|
15
|
|
|
* @package Tests\Unit\TestResult |
|
16
|
|
|
*/ |
|
17
|
|
|
class TestResultContainerTest extends BaseUnitTestCase |
|
18
|
|
|
{ |
|
19
|
|
|
public function testAddProcessToFilenames() |
|
20
|
|
|
{ |
|
21
|
|
|
$testResultFormat = $this->prophesize(TestResultFormat::class); |
|
22
|
|
|
$testResultContainer = new TestResultContainer($testResultFormat->reveal()); |
|
23
|
|
|
|
|
24
|
|
|
$unitTestProcess = new StubbedParaunitProcess('phpunit Unit/ClassTest.php'); |
|
25
|
|
|
$unitTestProcess->setFilename('ClassTest.php'); |
|
26
|
|
|
$functionalTestProcess = new StubbedParaunitProcess('phpunit Functional/ClassTest.php'); |
|
27
|
|
|
$functionalTestProcess->setFilename('ClassTest.php'); |
|
28
|
|
|
|
|
29
|
|
|
$testResultContainer->addProcessToFilenames($unitTestProcess); |
|
30
|
|
|
$testResultContainer->addProcessToFilenames($functionalTestProcess); |
|
31
|
|
|
|
|
32
|
|
|
$this->assertCount(2, $testResultContainer->getFileNames()); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
View Code Duplication |
public function testHandleLogItemAddsProcessOutputWhenNeeded() |
|
|
|
|
|
|
36
|
|
|
{ |
|
37
|
|
|
$testResult = new TestResultWithAbnormalTermination('function name', 'fail message'); |
|
38
|
|
|
$process = new StubbedParaunitProcess(); |
|
39
|
|
|
$process->setOutput('test output'); |
|
40
|
|
|
|
|
41
|
|
|
$testResultContainer = new TestResultContainer($this->mockTestFormat()); |
|
42
|
|
|
$testResultContainer->handleTestResult($process, $testResult); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertContains('fail message', $testResult->getFailureMessage()); |
|
45
|
|
|
$this->assertContains('test output', $testResult->getFailureMessage()); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
View Code Duplication |
public function testHandleLogItemAddsMessageWhenProcessOutputIsEmpty() |
|
|
|
|
|
|
49
|
|
|
{ |
|
50
|
|
|
$testResult = new TestResultWithAbnormalTermination('function name', 'fail message'); |
|
51
|
|
|
$process = new StubbedParaunitProcess(); |
|
52
|
|
|
$process->setOutput(''); |
|
53
|
|
|
|
|
54
|
|
|
$testResultContainer = new TestResultContainer($this->mockTestFormat()); |
|
55
|
|
|
$testResultContainer->handleTestResult($process, $testResult); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertContains('fail message', $testResult->getFailureMessage()); |
|
58
|
|
|
$this->assertContains('<tag><[NO OUTPUT FOUND]></tag>', $testResult->getFailureMessage()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
View Code Duplication |
public function testCountTestResultsCountsOnlyResultsWhichProducesSymbols() |
|
|
|
|
|
|
62
|
|
|
{ |
|
63
|
|
|
$testResult = new TestResultWithAbnormalTermination('function name', 'some message'); |
|
64
|
|
|
$process = new StubbedParaunitProcess(); |
|
65
|
|
|
$process->setOutput(''); |
|
66
|
|
|
$testFormat = $this->prophesize(TestResultFormat::class); |
|
67
|
|
|
$testFormat->getTag() |
|
68
|
|
|
->willReturn('tag'); |
|
69
|
|
|
|
|
70
|
|
|
$testResultContainer = new TestResultContainer($testFormat->reveal()); |
|
71
|
|
|
$testResultContainer->handleTestResult($process, $testResult); |
|
72
|
|
|
|
|
73
|
|
|
$this->assertSame(0, $testResultContainer->countTestResults()); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: