Completed
Push — output_parsers_refactor ( 755930...b5c5df )
by Alessandro
07:17
created

JSONLogFetcherTest::testFetch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace Paraunit\Tests\Unit\Parser;
4
5
use Paraunit\Parser\JSONLogFetcher;
6
use Paraunit\Tests\BaseUnitTestCase;
7
use Paraunit\Tests\Stub\StubbedParaProcess;
8
9
/**
10
 * Class JSONLogFetcherTest
11
 * @package Paraunit\Tests\Unit\Parser
12
 */
13
class JSONLogFetcherTest extends BaseUnitTestCase
14
{
15
    public function testFetchThrowsExceptionWithMissingLog()
16
    {
17
        $process = new StubbedParaProcess();
18
19
        $fileName = $this->prophesize('Paraunit\Configuration\JSONLogFilename');
20
        $fileName->generate($process)->willReturn('non-existent-log.json');
21
22
        $fetcher = new JSONLogFetcher($fileName->reveal());
23
24
        $this->setExpectedException('Paraunit\Exception\JSONLogNotFoundException');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
25
26
        $fetcher->fetch($process);
27
    }
28
29
    public function testFetch()
30
    {
31
        $process = new StubbedParaProcess();
32
        $filename = __DIR__ . '/../../Stub/PHPUnitOutput/JSONLogs/AllGreen.json';
33
        $this->assertTrue(file_exists($filename), 'Test malformed, stub log file not found');
34
35
        $fileNameService = $this->prophesize('Paraunit\Configuration\JSONLogFilename');
36
        $fileNameService->generate($process)->willReturn($filename);
37
38
39
        $fetcher = new JSONLogFetcher($fileNameService->reveal());
40
41
        $logs = $fetcher->fetch($process);
42
43
        $this->assertNotNull($logs, 'Fetcher returning a non-array');
44
        $this->assertTrue(is_array($logs), 'Fetcher returning a non-array');
45
        $this->assertCount(20, $logs);
46
        $this->assertContainsOnlyInstancesOf('\stdClass', $logs);
47
    }
48
}
49