1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Tests\Unit\Printer; |
6
|
|
|
|
7
|
|
|
use Paraunit\Printer\FinalPrinter; |
8
|
|
|
use Paraunit\TestResult\TestResultContainer; |
9
|
|
|
use Paraunit\TestResult\TestResultList; |
10
|
|
|
use Symfony\Bridge\PhpUnit\ClockMock; |
11
|
|
|
use Symfony\Component\Stopwatch\Stopwatch; |
12
|
|
|
use Tests\BaseUnitTestCase; |
13
|
|
|
use Tests\Stub\UnformattedOutputStub; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class FailuresPrinterTest |
17
|
|
|
* @package Tests\Unit\Printer |
18
|
|
|
*/ |
19
|
|
|
class FinalPrinterTest extends BaseUnitTestCase |
20
|
|
|
{ |
21
|
|
|
public function testOnEngineEndPrintsTheRightCountSummary() |
22
|
|
|
{ |
23
|
|
|
ClockMock::register(Stopwatch::class); |
24
|
|
|
ClockMock::register(__CLASS__); |
25
|
|
|
$output = new UnformattedOutputStub(); |
26
|
|
|
|
27
|
|
|
$testResultContainer = $this->prophesize(TestResultContainer::class); |
28
|
|
|
$testResultContainer->countTestResults() |
29
|
|
|
->willReturn(3); |
30
|
|
|
$testResultContainer->getTestResults() |
31
|
|
|
->willReturn(array_fill(0, 3, $this->mockTestResult())); |
32
|
|
|
$testResultContainer->getTestResultFormat() |
33
|
|
|
->willReturn($this->mockTestFormat()); |
34
|
|
|
$testResultContainer->getFileNames() |
35
|
|
|
->willReturn(['Test.php']); |
36
|
|
|
|
37
|
|
|
$testResultList = $this->prophesize(TestResultList::class); |
38
|
|
|
$testResultList->getTestResultContainers() |
39
|
|
|
->willReturn(array_fill(0, 15, $testResultContainer->reveal())); |
40
|
|
|
|
41
|
|
|
$printer = new FinalPrinter($testResultList->reveal(), $output); |
42
|
|
|
|
43
|
|
|
ClockMock::withClockMock(true); |
44
|
|
|
|
45
|
|
|
$printer->onEngineStart(); |
46
|
|
|
$printer->onProcessTerminated(); |
47
|
|
|
$printer->onProcessTerminated(); |
48
|
|
|
$printer->onProcessTerminated(); |
49
|
|
|
$printer->onProcessTerminated(); |
50
|
|
|
$printer->onProcessTerminated(); |
51
|
|
|
$printer->onProcessToBeRetried(); |
52
|
|
|
$printer->onProcessTerminated(); |
53
|
|
|
usleep(60499999); |
54
|
|
|
$printer->onEngineEnd(); |
55
|
|
|
|
56
|
|
|
ClockMock::withClockMock(false); |
57
|
|
|
|
58
|
|
|
$this->assertContains('Execution time -- 00:01:00', $output->getOutput()); |
59
|
|
|
$this->assertContains('Executed: 5 test classes (1 retried), 44 tests', $output->getOutput()); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testOnEngineEndHandlesEmptyMessagesCorrectly() |
63
|
|
|
{ |
64
|
|
|
$testResultContainer = $this->prophesize(TestResultContainer::class); |
65
|
|
|
$testResultContainer->countTestResults() |
66
|
|
|
->willReturn(3); |
67
|
|
|
$testResultContainer->getTestResults() |
68
|
|
|
->willReturn(array_fill(0, 3, $this->mockTestResult())); |
69
|
|
|
$testResultContainer->getTestResultFormat() |
70
|
|
|
->willReturn($this->mockTestFormat()); |
71
|
|
|
$testResultContainer->getFileNames() |
72
|
|
|
->willReturn(['Test.php']); |
73
|
|
|
|
74
|
|
|
$testResultList = $this->prophesize(TestResultList::class); |
75
|
|
|
$testResultList->getTestResultContainers() |
76
|
|
|
->willReturn(array_fill(0, 15, $testResultContainer->reveal())); |
77
|
|
|
$output = new UnformattedOutputStub(); |
78
|
|
|
|
79
|
|
|
$printer = new FinalPrinter($testResultList->reveal(), $output); |
80
|
|
|
|
81
|
|
|
$printer->onEngineStart(); |
82
|
|
|
$printer->onEngineEnd(); |
83
|
|
|
|
84
|
|
|
$this->assertNotContains('output', $output->getOutput()); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|