Passed
Push — master ( ad7958...88028e )
by Alexander
03:19 queued 01:10
created

BootstrapGroupTest::testRunningItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Horat1us\Yii\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use Horat1us\Yii\BootstrapGroup;
9
use yii\console;
10
use yii\base;
11
12
/**
13
 * Class BootstrapGroupTest
14
 * @package Horat1us\Yii\Tests
15
 */
16
class BootstrapGroupTest extends TestCase
17
{
18
    public function testRunningItems(): void
19
    {
20
        /** @var console\Application $app */
21
        $app = $this->createMock(console\Application::class);
22
        $group = new BootstrapGroup();
23
24
        $child = $this->createMock(BootstrapGroup::class);
25
26
        $child
27
            ->expects($this->exactly(2))
28
            ->method('bootstrap')
29
            ->with($app);
30
31
        $group->items = [
32
            $child,
33
            $child,
34
        ];
35
36
        /** @noinspection PhpUnhandledExceptionInspection */
37
        $group->bootstrap($app);
38
    }
39
40
    public function testInvalidReference(): void
41
    {
42
        /** @var console\Application $app */
43
        $app = $this->createMock(console\Application::class);
44
        $group = new BootstrapGroup([
45
            'items' => [
46
                new \stdClass,
47
            ],
48
        ]);
49
50
        $this->expectException(base\InvalidConfigException::class);
51
        /** @noinspection PhpUnhandledExceptionInspection */
52
        $group->bootstrap($app);
53
    }
54
}
55