Passed
Branch master (4bec7e)
by Stanislau
32:39 queued 29:56
created

LocatorPluginTest::testPlugin()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 3
eloc 12
nc 4
nop 0
dl 0
loc 24
rs 9.8666
c 2
b 1
f 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\Plugin\Locator\Test\Unit;
15
16
use Micro\Kernel\App\AppKernel;
17
use Micro\Plugin\EventEmitter\Business\Locator\EventListenerClassLocatorInterface;
18
use Micro\Plugin\Locator\Facade\LocatorFacadeInterface;
19
use PHPUnit\Framework\TestCase;
20
21
class LocatorPluginTest extends TestCase
22
{
23
    public function testPlugin()
24
    {
25
        $kernel = new AppKernel(
26
            [],
27
            [
28
                \stdClass::class,
29
            ],
30
            'dev'
31
        );
32
33
        $kernel->run();
34
        /** @var LocatorFacadeInterface $locator */
35
        $locator = $kernel->container()->get(LocatorFacadeInterface::class);
36
        $i = 0;
37
        foreach ($locator->lookup(EventListenerClassLocatorInterface::class) as $internalClass) {
38
            ++$i;
39
            $this->assertTrue(\in_array(EventListenerClassLocatorInterface::class, class_implements($internalClass)));
40
        }
41
42
        foreach ($locator->lookup('ClassNoExists') as $plugin) {
43
            throw new \Exception('Oh, no.');
44
        }
45
46
        $this->assertTrue((bool) $i);
47
    }
48
}
49