@@ 17-24 (lines=8) @@ | ||
14 | ||
15 | class ProviderTest extends TestCase |
|
16 | { |
|
17 | public function testAttachCallableArray() |
|
18 | { |
|
19 | $provider = new Provider(); |
|
20 | $provider->attach([WithStaticMethod::class, 'handle']); |
|
21 | ||
22 | $listeners = $provider->getListenersForEvent(new Event()); |
|
23 | $this->assertCount(1, $listeners); |
|
24 | } |
|
25 | ||
26 | public function testAttachCallableFunction() |
|
27 | { |
|
@@ 26-33 (lines=8) @@ | ||
23 | $this->assertCount(1, $listeners); |
|
24 | } |
|
25 | ||
26 | public function testAttachCallableFunction() |
|
27 | { |
|
28 | $provider = new Provider(); |
|
29 | $provider->attach('Yiisoft\EventDispatcher\Tests\Provider\handle'); |
|
30 | ||
31 | $listeners = $provider->getListenersForEvent(new Event()); |
|
32 | $this->assertCount(1, $listeners); |
|
33 | } |
|
34 | ||
35 | public function testAttachClosure() |
|
36 | { |
|
@@ 35-44 (lines=10) @@ | ||
32 | $this->assertCount(1, $listeners); |
|
33 | } |
|
34 | ||
35 | public function testAttachClosure() |
|
36 | { |
|
37 | $provider = new Provider(); |
|
38 | $provider->attach(function (Event $event) { |
|
39 | // do nothing |
|
40 | }); |
|
41 | ||
42 | $listeners = $provider->getListenersForEvent(new Event()); |
|
43 | $this->assertCount(1, $listeners); |
|
44 | } |
|
45 | ||
46 | public function testAttachCallableObject() |
|
47 | { |
|
@@ 46-53 (lines=8) @@ | ||
43 | $this->assertCount(1, $listeners); |
|
44 | } |
|
45 | ||
46 | public function testAttachCallableObject() |
|
47 | { |
|
48 | $provider = new Provider(); |
|
49 | $provider->attach([new NonStatic(), 'handle']); |
|
50 | ||
51 | $listeners = $provider->getListenersForEvent(new Event()); |
|
52 | $this->assertCount(1, $listeners); |
|
53 | } |
|
54 | ||
55 | public function testInvokable() |
|
56 | { |
|
@@ 55-62 (lines=8) @@ | ||
52 | $this->assertCount(1, $listeners); |
|
53 | } |
|
54 | ||
55 | public function testInvokable() |
|
56 | { |
|
57 | $provider = new Provider(); |
|
58 | $provider->attach(new Invokable()); |
|
59 | ||
60 | $listeners = $provider->getListenersForEvent(new Event()); |
|
61 | $this->assertCount(1, $listeners); |
|
62 | } |
|
63 | ||
64 | public function testListenersForClassHierarchyAreReturned() |
|
65 | { |