Skip to content

Commit 9ecb146

Browse files
authored
[9.x] Add test for assertListening in EventFake (#41875)
1 parent bb9a897 commit 9ecb146

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/Support/SupportTestingEventFakeTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ public function testAssertDispatchedWithClosure()
4646
});
4747
}
4848

49+
public function testAssertListening()
50+
{
51+
$listener = ListenerStub::class;
52+
53+
$dispatcher = m::mock(Dispatcher::class);
54+
$dispatcher->shouldReceive('getListeners')->andReturn([function ($event, $payload) use ($listener) {
55+
return $listener(...array_values($payload));
56+
}]);
57+
58+
$fake = new EventFake($dispatcher);
59+
60+
$fake->assertListening(EventStub::class, ListenerStub::class);
61+
}
62+
4963
public function testAssertDispatchedWithCallbackInt()
5064
{
5165
$this->fake->dispatch(EventStub::class);
@@ -145,3 +159,8 @@ class EventStub
145159
{
146160
//
147161
}
162+
163+
class ListenerStub
164+
{
165+
//
166+
}

0 commit comments

Comments
 (0)