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'); |
|
|
|
|
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
|
|
|
|
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.