1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Paraunit\Tests\Functional\Parser; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use Paraunit\Configuration\JSONLogFilename; |
7
|
|
|
use Paraunit\Parser\JSONLogParser; |
8
|
|
|
use Paraunit\Tests\BaseFunctionalTestCase; |
9
|
|
|
use Paraunit\Tests\Stub\PHPUnitOutput\JSONLogs\JSONLogStub; |
10
|
|
|
use Paraunit\Tests\Stub\StubbedParaProcess; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class JSONLogParserTest |
14
|
|
|
* @package Paraunit\Tests\Functional\Parser |
15
|
|
|
*/ |
16
|
|
|
class JSONLogParserTest extends BaseFunctionalTestCase |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @dataProvider parsableResultsProvider |
20
|
|
|
*/ |
21
|
|
|
public function testParse($stubLog, $expectedResult, $hasAbnormalTermination = false) |
22
|
|
|
{ |
23
|
|
|
$process = new StubbedParaProcess(); |
24
|
|
|
$stubLogFilename = __DIR__ . '/../../Stub/PHPUnitOutput/JSONLogs/' . $stubLog . '.json'; |
25
|
|
|
$this->assertTrue(file_exists($stubLogFilename), 'Stub log file missing!'); |
26
|
|
|
|
27
|
|
|
/** @var JSONLogFilename $filename */ |
28
|
|
|
$filenameService = $this->container->get('paraunit.configuration.json_log_filename'); |
29
|
|
|
$filename = $filenameService->generate($process); |
30
|
|
|
|
31
|
|
|
copy($stubLogFilename, $filename); |
32
|
|
|
|
33
|
|
|
/** @var JSONLogParser $parser */ |
34
|
|
|
$parser = $this->container->get('paraunit.parser.json_log_parser'); |
35
|
|
|
|
36
|
|
|
$parser->parse($process); |
37
|
|
|
unlink($filename); // TODO -- cancellare tutto nel teardown |
38
|
|
|
|
39
|
|
|
$this->assertEquals($expectedResult, $process->getTestResults()); |
40
|
|
|
if ($hasAbnormalTermination) { |
41
|
|
|
$this->assertTrue($process->hasAbnormalTermination()); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
public function parsableResultsProvider() |
47
|
|
|
{ |
48
|
|
|
return array( |
49
|
|
|
array(JSONLogStub::TWO_ERRORS_TWO_FAILURES, str_split('FF..E...E')), |
50
|
|
|
array(JSONLogStub::ALL_GREEN, str_split('.........')), |
51
|
|
|
array(JSONLogStub::ONE_ERROR, str_split('.E.')), |
52
|
|
|
array(JSONLogStub::ONE_INCOMPLETE, str_split('..I.')), |
53
|
|
|
array(JSONLogStub::ONE_RISKY, str_split('..R.')), |
54
|
|
|
array(JSONLogStub::ONE_SKIP, str_split('..S.')), |
55
|
|
|
array(JSONLogStub::ONE_WARNING, str_split('...W')), |
56
|
|
|
array(JSONLogStub::FATAL_ERROR, str_split('...X'), true), |
57
|
|
|
array(JSONLogStub::SEGFAULT, str_split('...X'), true), |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|