|
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
|
|
|
public function testParseMarksAbnormalTerminationsForNotFoundLogs() |
|
19
|
|
|
{ |
|
20
|
|
|
$process = new StubbedParaProcess(); |
|
21
|
|
|
|
|
22
|
|
|
/** @var JSONLogParser $parser */ |
|
23
|
|
|
$parser = $this->container->get('paraunit.parser.json_log_parser'); |
|
24
|
|
|
|
|
25
|
|
|
$this->markTestIncomplete(); |
|
26
|
|
|
$parser->parse($process); |
|
27
|
|
|
|
|
28
|
|
|
$this->assertTrue($process->hasAbnormalTermination()); |
|
|
|
|
|
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @dataProvider parsableResultsProvider |
|
33
|
|
|
*/ |
|
34
|
|
|
public function testParse($log, $expectedResult) |
|
35
|
|
|
{ |
|
36
|
|
|
$process = new StubbedParaProcess(); |
|
37
|
|
|
|
|
38
|
|
|
/** @var JSONLogFilename $filename */ |
|
39
|
|
|
$filenameService = $this->container->get('paraunit.configuration.json_log_filename'); |
|
40
|
|
|
$filename = $filenameService->generate($process); |
|
41
|
|
|
|
|
42
|
|
|
$res = fopen($filename, 'w'); |
|
43
|
|
|
fwrite($res, $log); |
|
44
|
|
|
fclose($res); |
|
45
|
|
|
|
|
46
|
|
|
/** @var JSONLogParser $parser */ |
|
47
|
|
|
$parser = $this->container->get('paraunit.parser.json_log_parser'); |
|
48
|
|
|
|
|
49
|
|
|
$parser->parse($process); |
|
50
|
|
|
unlink($filename); |
|
51
|
|
|
|
|
52
|
|
|
$this->assertEquals($expectedResult, $process->getTestResults()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function parsableResultsProvider() |
|
56
|
|
|
{ |
|
57
|
|
|
return array( |
|
58
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::TWO_ERRORS_TWO_FAILURES), str_split('FF..E...E')), |
|
59
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ALL_GREEN), str_split('.........')), |
|
60
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::FATAL_ERROR), str_split('...')), |
|
61
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::SEGFAULT), str_split('...')), |
|
62
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_ERROR), str_split('.E.')), |
|
63
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_INCOMPLETE), str_split('..I.')), |
|
64
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_RISKY), str_split('..R.')), |
|
65
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_SKIP), str_split('..S.')), |
|
66
|
|
|
array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_WARNING), str_split('...W')), |
|
67
|
|
|
); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.