Passed
Push — master ( 2ed18b...d69bd8 )
by Caen
04:33 queued 17s
created

anonymous//packages/realtime-compiler/tests/ConsoleOutputTest.php$0   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 10
wmc 1
1
<?php
2
3
use Hyde\Foundation\HydeKernel;
4
use Symfony\Component\Console\Output\BufferedOutput;
5
use Termwind\Repositories\Styles;
6
7
use function Termwind\{renderUsing};
8
9
uses(\Hyde\Testing\UnitTestCase::class);
10
11
beforeEach(function () {
12
    renderUsing($this->output = new BufferedOutput());
13
14
    $this::mockConfig();
15
});
16
17
afterEach(function () {
18
    renderUsing(null);
19
20
    Styles::flush();
21
22
    HydeKernel::setInstance(new HydeKernel());
23
});
24
25
test('printStartMessage method', function () {
26
    HydeKernel::setInstance(new class extends HydeKernel
27
    {
28
        public static function version(): string
29
        {
30
            return '1.2.3';
31
        }
32
    });
33
34
    $output = new \Hyde\RealtimeCompiler\ConsoleOutput();
35
    $output->printStartMessage('localhost', 8000);
36
    $this->assertSame(<<<'TXT'
37
38
     ╭─────────────────────────────────────╮
39
     │                                     │
40
     │ HydePHP Realtime Compiler v1.2.3    │
41
     │                                     │
42
     │ Listening on: http://localhost:8000 │
43
     │                                     │
44
     ╰─────────────────────────────────────╯
45
46
47
    TXT, str_replace(["\u{A0}", "\r"], [' ', ''], $this->output->fetch()));
48
});
49