Test Failed
Pull Request — master (#132)
by Alessandro
03:15
created

LogPrinterTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testWrite() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests\Functional\Parser\JSON;
6
7
use Paraunit\Configuration\EnvVariables;
8
use Paraunit\Parser\JSON\LogPrinter;
9
use PHPUnit\Framework\TestSuite;
10
use Tests\BaseFunctionalTestCase;
11
12
/**
13
 * Class LogPrinterTest
14
 * @package Tests\Functional\Parser\JSON
15
 */
16
class LogPrinterTest extends BaseFunctionalTestCase
17
{
18
    protected function setUp()
19
    {
20
        parent::setUp();
21
22
        $this->createRandomTmpDir();
23
    }
24
25
    public function testWrite()
26
    {
27
        $testName = __CLASS__;
28
        $testSuite = $this->prophesize(TestSuite::class);
29
        $testSuite->getName()
30
            ->willReturn($testName);
31
        $testSuite->count()
32
            ->willReturn(1);
33
34
        putenv(EnvVariables::PROCESS_UNIQUE_ID . '=' . md5(__FILE__));
35
        $logFullPath = $this->getRandomTempDir() . md5(__FILE__) . '.json.log';
36
37
        $printer = new LogPrinter();
38
39
        $printer->startTestSuite($testSuite->reveal());
40
41
        $content = $this->getFileContent($logFullPath);
42
        $this->assertJson($content);
43
        $decodedJson = json_decode($content, true);
44
        $this->assertEquals(['event' => 'suiteStart', 'suite' => $testName, 'tests' => 1], $decodedJson);
45
    }
46
}
47