|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Paraunit\Tests\Unit\Parser; |
|
4
|
|
|
|
|
5
|
|
|
use Paraunit\Exception\JSONLogNotFoundException; |
|
6
|
|
|
use Paraunit\Exception\RecoverableTestErrorException; |
|
7
|
|
|
use Paraunit\Parser\JSONLogParser; |
|
8
|
|
|
use Paraunit\Tests\Stub\PHPUnitOutput\JSONLogs\JSONLogStub; |
|
9
|
|
|
use Paraunit\Tests\Stub\StubbedParaProcess; |
|
10
|
|
|
use Prophecy\Argument; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class JSONLogParserTest |
|
14
|
|
|
* @package Paraunit\Tests\Unit\Parser |
|
15
|
|
|
*/ |
|
16
|
|
|
class JSONLogParserTest extends \PHPUnit_Framework_TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @dataProvider parsableResultsProvider |
|
20
|
|
|
*/ |
|
21
|
|
|
public function testParse($chainedParsersResults) |
|
22
|
|
|
{ |
|
23
|
|
|
$chainedParsers = $this->mockChainedParsers($chainedParsersResults); |
|
24
|
|
|
$process = new StubbedParaProcess(); |
|
25
|
|
|
$logLocator = $this->prophesize('Paraunit\Parser\JSONLogFetcher'); |
|
26
|
|
|
$logLocator->fetch($process)->willReturn(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ALL_GREEN)); |
|
27
|
|
|
$parser = new JSONLogParser($logLocator->reveal()); |
|
28
|
|
|
foreach ($chainedParsers as $chainedParser) { |
|
29
|
|
|
$parser->addParser($chainedParser); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
$parser->parse($process); |
|
33
|
|
|
|
|
34
|
|
|
$this->markTestIncomplete('non so cosa controllare'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function parsableResultsProvider() |
|
38
|
|
|
{ |
|
39
|
|
|
return array( |
|
40
|
|
|
array(array(true)), |
|
41
|
|
|
array(array(false, true)), |
|
42
|
|
|
array(array(false, false)), |
|
43
|
|
|
); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
private function mockChainedParsers(array $results) |
|
47
|
|
|
{ |
|
48
|
|
|
$mocks = array(); |
|
49
|
|
|
foreach ($results as $result) { |
|
50
|
|
|
$parser = $this->prophesize('Paraunit\Parser\JSONParserChainElementInterface'); |
|
51
|
|
|
$parser->parsingFoundResult(Argument::cetera())->willReturn($result); |
|
52
|
|
|
|
|
53
|
|
|
$mocks[] = $parser->reveal(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return $mocks; |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|