Passed
Pull Request — master (#257)
by Wilmer
28:13 queued 13:12
created

ResultPrinter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 25
rs 10
c 2
b 0
f 0
eloc 8
wmc 4
1
<?php
2
3
namespace Yiisoft\Yii\Web\Tests;
4
5
use PHPUnit\TextUI\DefaultResultPrinter;
6
7
/**
8
 * Class ResultPrinter overrides \PHPUnit\TextUI\ResultPrinter constructor
9
 * to change default output to STDOUT and prevent some tests from fail when
10
 * they can not be executed after headers have been sent.
11
 */
12
class ResultPrinter extends DefaultResultPrinter
13
{
14
    private bool $isStdout;
15
16
    public function __construct(
17
        $out = null,
18
        $verbose = false,
19
        $colors = \PHPUnit\TextUI\ResultPrinter::COLOR_DEFAULT,
20
        $debug = false,
21
        $numberOfColumns = 80,
22
        $reverse = false
23
    ) {
24
        if ($out === null) {
25
            $out = STDOUT;
26
        }
27
28
        $this->isStdout = $out === STDOUT;
29
30
        parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns, $reverse);
31
    }
32
33
    public function flush(): void
34
    {
35
        if ($this->isStdout) {
36
            parent::flush();
37
        }
38
    }
39
}
40