Completed
Push — output_parsers_refactor ( 9ffc6c...755930 )
by Alessandro
09:57
created

JSONLogParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 5
dl 0
loc 54
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testParseMarksAbnormalTerminationsForNotFoundLogs() 0 12 1
A testParse() 0 20 1
A parsableResultsProvider() 0 14 1
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());
0 ignored issues
show
Bug introduced by
The method hasAbnormalTermination() does not seem to exist on object<Paraunit\Tests\Stub\StubbedParaProcess>.

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.

Loading history...
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