KernelBuilderTest::testBootLoaders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 15
rs 9.9666
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Framework\Kernel\Test\Unit;
15
16
use Micro\Component\DependencyInjection\Container;
17
use Micro\Framework\Kernel\KernelBuilder;
18
use Micro\Framework\Kernel\KernelInterface;
19
use Micro\Framework\Kernel\Plugin\PluginBootLoaderInterface;
20
use PHPUnit\Framework\TestCase;
21
22
class KernelBuilderTest extends TestCase
23
{
24
    private KernelBuilder $builder;
25
26
    protected function setUp(): void
27
    {
28
        $this->builder = new KernelBuilder();
29
    }
30
31
    public function testBuildWithoutContainer()
32
    {
33
        $kernel = $this->builder
34
            ->setApplicationPlugins([])
35
            ->build();
36
37
        $this->assertInstanceOf(KernelInterface::class, $kernel);
38
    }
39
40
    public function testBuildWithContainer()
41
    {
42
        $container = new Container();
43
44
        $kernel = $this->builder
45
            ->setApplicationPlugins([])
46
            ->setContainer($container)
47
            ->build();
48
49
        $this->assertInstanceOf(KernelInterface::class, $kernel);
50
        $this->assertEquals($container, $kernel->container());
51
    }
52
53
    public function testBootLoaders()
54
    {
55
        $kernel = $this->builder
56
            ->setApplicationPlugins([
57
                \stdClass::class,
58
            ])
59
            ->addBootLoaders([
60
                $this->createBootLoader(),
61
                $this->createBootLoader(),
62
            ])
63
            ->addBootLoader($this->createBootLoader())
64
            ->build()
65
        ;
66
67
        $kernel->run();
68
    }
69
70
    protected function createBootLoader()
71
    {
72
        $bl = $this->createMock(PluginBootLoaderInterface::class);
73
        $bl
74
            ->expects($this->once())
75
            ->method('boot');
76
77
        return $bl;
78
    }
79
}
80