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

BaseUnitTestCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getLogWithStatus() 0 16 5
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