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

BaseUnitTestCase::getLogWithStatus()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 8.8571
cc 5
eloc 9
nc 4
nop 2
1
<?php
2
3
namespace Paraunit\Tests;
4
use Paraunit\Tests\Stub\PHPUnitOutput\JSONLogs\JSONLogStub;
5
6
/**
7
 * Class BaseUnitTestCase
8
 * @package Paraunit\Tests
9
 */
10
abstract class BaseUnitTestCase extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * @param $testOutput
14
     * @return \stdClass
15
     */
16
    protected function getLogWithStatus($status, $testOutput = null)
17
    {
18
        $jsonLogs = JSONLogStub::getCleanOutputFileContent(JSONLogStub::ONE_ERROR);
19
        $logs = json_decode($jsonLogs);
20
        foreach ($logs as $log) {
21
            if ($log->event == 'test' && $log->status == $status) {
22
                if ($testOutput) {
23
                    $log->message = $testOutput;
24
                }
25
26
                return $log;
27
            }
28
        }
29
30
        $this->fail('Feasible log message not found for test');
31
    }
32
}
33