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

LogPrinterTest::testWrite()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 0
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