Completed
Push — master ( 904e9e...12cc86 )
by Dmitry
05:35
created

EventTest::test()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Test;
4
5
use Basis\Converter;
6
use Basis\Event;
7
use Basis\Test;
8
9
class EventTest extends Test
10
{
11
    public $mocks = [
12
        ['event.fire', [], 'fireEvent']
13
    ];
14
15
    private $firedEvents = [];
16
17
    public function fireEvent($params)
18
    {
19
        $this->firedEvents[] = $params;
20
    }
21
22
    public function testEventFire()
23
    {
24
        $this->get(Event::class)->fire('person.authorized', ['name' => 'nekufa']);
25
        $this->assertCount(1, $this->firedEvents);
26
        $this->assertSame($this->firedEvents[0]->event, 'test.person.authorized');
27
        $this->assertSame(get_object_vars($this->firedEvents[0]->context), ['name' => 'nekufa']);
28
    }
29
30
    public function testSubscription()
31
    {
32
        $event = $this->get(Event::class);
33
        $subscription = $event->getSubscription();
34
35
        $this->assertArrayHasKey('person.created', $subscription);
36
        $this->assertSame($subscription['person.created'], ['CreateLogin']);
37
    }
38
}
39