Passed
Pull Request — master (#277)
by Kirill
03:11
created

KernelTest::testInvalidRPC2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Framework;
13
14
use Spiral\Boot\Environment;
15
use Spiral\Boot\Exception\BootException;
16
use Spiral\Config\ConfiguratorInterface;
17
use Spiral\Goridge\RPC;
18
use Spiral\RoadRunner\Worker;
19
use Spiral\App\TestApp;
20
21
class KernelTest extends BaseTest
22
{
23
    public function testBypassEnvironmentToConfig(): void
24
    {
25
        $configs = $this->makeApp([
26
            'TEST_VALUE' => 'HELLO WORLD'
27
        ])->get(ConfiguratorInterface::class);
28
29
        $this->assertSame([
30
            'key' => 'HELLO WORLD'
31
        ], $configs->getConfig('test'));
32
    }
33
34
    public function testGetEnv(): void
35
    {
36
        $app = $this->makeApp([
37
            'DEBUG' => true,
38
            'ENV'   => 123
39
        ]);
40
41
        $this->assertSame(123, $app->getEnvironment()->get('ENV'));
42
    }
43
44
    public function testNoRootDirectory(): void
45
    {
46
        $this->expectException(BootException::class);
47
48
        TestApp::init([
49
        ], new Environment(), false);
50
    }
51
52
    public function testWorker(): void
53
    {
54
        /** @var Worker $worker */
55
        $worker = $this->makeApp([])->get(Worker::class);
56
        $this->assertInstanceOf(Worker::class, $worker);
57
    }
58
59
    public function testDefaultRPC(): void
60
    {
61
        /** @var RPC $rpc */
62
        $rpc = $this->makeApp([])->get(RPC::class);
63
        $this->assertInstanceOf(RPC::class, $rpc);
64
    }
65
66
    public function testInvalidRPC(): void
67
    {
68
        $this->expectException(BootException::class);
69
70
        $this->makeApp([
71
            'RR_RPC' => 'invalid'
72
        ])->get(RPC::class);
73
    }
74
75
    public function testInvalidRPC2(): void
76
    {
77
        $this->expectException(BootException::class);
78
79
        $this->makeApp([
80
            'RR_RPC' => 'ftp://magic'
81
        ])->get(RPC::class);
82
    }
83
}
84