Passed
Push — main ( 9c59f2...5fac80 )
by Peter
02:52
created

EventDispatcherBootstrapperTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace AbterPhp\Framework\Bootstrappers\Events;
4
5
use Opulence\Events\Dispatchers\EventRegistry;
6
use Opulence\Events\Dispatchers\IEventDispatcher;
7
use Opulence\Ioc\Container;
8
use PHPUnit\Framework\TestCase;
9
10
class EventDispatcherBootstrapperTest extends TestCase
11
{
12
    protected EventDispatcherBootstrapper $sut;
13
14
    public function setUp(): void
15
    {
16
        $this->sut = new EventDispatcherBootstrapper();
17
    }
18
19
    public function testRegisterBindings()
20
    {
21
        $listenerName = 'foo';
22
        $events1      = [$listenerName => [fn() => null]];
23
        $events2      = [$listenerName => [fn() => null]];
24
25
        $this->sut->setBaseEvents($events1);
26
        $this->sut->setModuleEvents($events2);
27
28
        $container = new Container();
29
30
        $this->sut->registerBindings($container);
31
32
        $actual = $container->resolve(IEventDispatcher::class);
33
        $this->assertInstanceOf(IEventDispatcher::class, $actual);
34
35
        /** @var EventRegistry $actual */
36
        $actual = $container->resolve(EventRegistry::class);
37
        $this->assertInstanceOf(EventRegistry::class, $actual);
38
        $this->assertCount(2, $actual->getListeners($listenerName));
39
    }
40
}
41