PrinterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 39
c 1
b 0
f 0
dl 0
loc 66
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testHookEndDebug() 0 17 1
A testHookEndVerbose() 0 19 1
A testHookEndVeryVerbose() 0 18 1
1
<?php
2
3
/**
4
 * This file is part of CaptainHook
5
 *
6
 * (c) Sebastian Feldmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CaptainHook\App\Runner\Hook;
13
14
use CaptainHook\App\Config\Action;
15
use CaptainHook\App\Console\IO;
16
use CaptainHook\App\Console\IO\Mockery as IOMockery;
17
use CaptainHook\App\Mockery as AppMockery;
18
use CaptainHook\App\Runner\Action\Log as ActionLog;
19
use CaptainHook\App\Runner\Hook as HookRunner;
20
use PHPUnit\Framework\TestCase;
21
22
class PrinterTest extends TestCase
23
{
24
    use AppMockery;
25
    use IOMockery;
26
27
    # @Test
28
    public function testHookEndDebug(): void
29
    {
30
        $io = $this->createIOMock();
31
        $io->method('isDebug')->willReturn(true);
32
        $io->expects($this->atLeast(2))->method('write');
33
34
        $log = new Log();
35
        $log->addActionLog(
36
            new ActionLog(
37
                new Action("foo"),
38
                ActionLog::ACTION_SUCCEEDED,
39
                [new IO\Message('foo', true, IO::DEBUG)]
40
            )
41
        );
42
43
        $printer = new Printer($io);
44
        $printer->hookEnded(HookRunner::HOOK_SUCCEEDED, $log, 0.25);
45
    }
46
47
    # @Test
48
    public function testHookEndVeryVerbose(): void
49
    {
50
        $io = $this->createIOMock();
51
        $io->method('isDebug')->willReturn(false);
52
        $io->method('isVeryVerbose')->willReturn(true);
53
        $io->expects($this->atLeast(2))->method('write');
54
55
        $log = new Log();
56
        $log->addActionLog(
57
            new ActionLog(
58
                new Action("foo"),
59
                ActionLog::ACTION_SUCCEEDED,
60
                [new IO\Message('foo', true, IO::VERY_VERBOSE)]
61
            )
62
        );
63
64
        $printer = new Printer($io);
65
        $printer->hookEnded(HookRunner::HOOK_SUCCEEDED, $log, 0.25);
66
    }
67
68
    # @Test
69
    public function testHookEndVerbose(): void
70
    {
71
        $io = $this->createIOMock();
72
        $io->method('isDebug')->willReturn(false);
73
        $io->method('isVeryVerbose')->willReturn(false);
74
        $io->method('isVerbose')->willReturn(true);
75
        $io->expects($this->atLeast(2))->method('write');
76
77
        $log = new Log();
78
        $log->addActionLog(
79
            new ActionLog(
80
                new Action("foo"),
81
                ActionLog::ACTION_SUCCEEDED,
82
                [new IO\Message('foo', true, IO::VERBOSE), new IO\Message('foo', true, IO::VERY_VERBOSE)]
83
            )
84
        );
85
86
        $printer = new Printer($io);
87
        $printer->hookEnded(HookRunner::HOOK_SUCCEEDED, $log, 0.25);
88
    }
89
}
90