Completed
Push — output_parsers_refactor ( 710907...9ffc6c )
by Alessandro
02:42
created

JSONLogParserTest::testParseAndContinue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 12
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
namespace Paraunit\Tests\Unit\Parser;
4
5
use Paraunit\Exception\JSONLogNotFoundException;
6
use Paraunit\Parser\JSONLogParser;
7
use Paraunit\Tests\Stub\PHPUnitOutput\JSONLogs\JSONLogStub;
8
use Paraunit\Tests\Stub\StubbedParaProcess;
9
10
/**
11
 * Class JSONLogParserTest
12
 * @package Paraunit\Tests\Unit\Parser
13
 */
14
class JSONLogParserTest extends \PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * @dataProvider parsableResultsProvider
18
     */
19 View Code Duplication
    public function testParseAndContinue($log, $expectedResult)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $process = new StubbedParaProcess();
22
        $logLocator = $this->prophesize('Paraunit\Parser\JSONLogFetcher');
23
        $logLocator->fetch($process)->willReturn(JSONLogStub::cleanLog($log));
24
25
        $parser = new JSONLogParser($logLocator->reveal());
26
27
        $this->assertFalse($parser->parseAndContinue($process));
28
29
        $this->assertEquals($expectedResult, $process->getTestResults());
30
    }
31
32
    public function parsableResultsProvider()
33
    {
34
        return array(
35
            array(JSONLogStub::get2Errors2Failures(), str_split('FF..E...E')),
36
            array(JSONLogStub::getAllGreen(), str_split('.........')),
37
            array(JSONLogStub::getFatalError(), str_split('...')),
38
            array(JSONLogStub::getSegFault(), str_split('...')),
39
            array(JSONLogStub::getSingleError(), str_split('.E.')),
40
            array(JSONLogStub::getSingleIncomplete(), str_split('..I.')),
41
            array(JSONLogStub::getSingleRisky(), str_split('..R.')),
42
            array(JSONLogStub::getSingleSkip(), str_split('..S.')),
43
            array(JSONLogStub::getSingleWarning(), str_split('...W')),
44
        );
45
    }
46
47 View Code Duplication
    public function testLogNotFound()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $process = new StubbedParaProcess();
50
        $logLocator = $this->prophesize('Paraunit\Parser\JSONLogFetcher');
51
        $logLocator->fetch($process)->willThrow(new JSONLogNotFoundException($process));
52
53
        $parser = new JSONLogParser($logLocator->reveal());
54
55
        $this->assertTrue($parser->parseAndContinue($process));
56
57
        $this->assertEmpty($process->getTestResults());
58
   }
59
}
60