Test Failed
Push — stable ( 994ca0...7d5c83 )
by Nuno
04:30
created

ApplicationTest::it_can_abort()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 3
nc 4
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests;
6
7
use Symfony\Component\Console\Exception\CommandNotFoundException;
8
use LaravelZero\Framework\Contracts\Exceptions\ConsoleExceptionContract;
9
10
final class ApplicationTest extends TestCase
11
{
12
    public function testVersionFromConfig(): void
13
    {
14
        $this->assertSame('Test version', $this->app->version());
15
    }
16
17
    public function testRunningInConsole(): void
18
    {
19
        $this->assertTrue($this->app->runningInConsole());
20
    }
21
22
    public function testIsDownForMaintenance(): void
23
    {
24
        $this->assertFalse($this->app->isDownForMaintenance());
25
    }
26
27
    public function testThatCanAbort(): void
28
    {
29
        try {
30
            $this->app->abort(404, 'Foo');
31
        } catch (CommandNotFoundException $notFoundException) {
32
        }
33
34
        $this->assertInstanceOf(CommandNotFoundException::class, $notFoundException);
35
        $this->assertEquals($notFoundException->getMessage(), 'Foo');
36
37
        try {
38
            abort(200, 'Bar', ['Foo' => 'Bar']);
39
        } catch (ConsoleExceptionContract $consoleException) {
40
        }
41
42
        $this->assertInstanceOf(ConsoleExceptionContract::class, $consoleException);
43
        $this->assertEquals($consoleException->getExitCode(), 200);
44
        $this->assertEquals($consoleException->getMessage(), 'Bar');
45
        $this->assertEquals($consoleException->getHeaders(), ['Foo' => 'Bar']);
46
    }
47
}
48