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

ErrorParserTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 42
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testParseAndContinue() 0 20 4
A logProvider() 0 15 1
1
<?php
2
3
namespace Paraunit\Tests\Unit\Parser;
4
5
use Paraunit\Parser\ErrorParser;
6
use Paraunit\Printer\OutputContainer;
7
use Paraunit\Tests\BaseUnitTestCase;
8
use Paraunit\Tests\Stub\PHPUnitOutput\JSONLogs\JSONLogStub;
9
use Paraunit\Tests\Stub\StubbedParaProcess;
10
use Paraunit\Tests\StubbedPHPUnitBaseTestCase;
11
12
/**
13
 * Class ErrorParserTest
14
 * @package Paraunit\Tests\Unit\Parser
15
 */
16
class ErrorParserTest extends BaseUnitTestCase
17
{
18
    /**
19
     * @dataProvider logProvider
20
     */
21
    public function testParseAndContinue($jsonLogs, $expectedErrorCount)
22
    {
23
        $outputContainer = new OutputContainer('tag', 'title');
24
        $parser = new ErrorParser($outputContainer);
25
        $process = new StubbedParaProcess();
26
        $logs = json_decode($jsonLogs);
27
28
        foreach ($logs as $singleLog) {
29
            if ($singleLog->event == 'test') {
30
                $parsingShouldContinue = $parser->parsingFoundResult($process, $singleLog);
31
                $this->assertSame($singleLog->status != 'error', $parsingShouldContinue);
32
            }
33
        }
34
35
        $this->assertEquals($expectedErrorCount, $parser->getOutputContainer()->countMessages());
36
        $this->assertCount($expectedErrorCount, $process->getTestResults());
37
        foreach ($process->getTestResults() as $testResult) {
38
            $this->assertEquals('E', $testResult);
39
        }
40
    }
41
42
    public function logProvider()
43
    {
44
        return array(
45
            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::TWO_ERRORS_TWO_FAILURES), 2),
46
            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ALL_GREEN), 0),
47
            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::FATAL_ERROR), 0),
48
            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::SEGFAULT), 0),
49
            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_ERROR), 1),
50
            // those will be intercepted before by other parsers
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
//            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_INCOMPLETE), 0),
52
//            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_RISKY), 1),
53
//            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_SKIP), 1),
54
//            array(JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_WARNING), 1),
55
        );
56
    }
57
}
58