@@ -73,6 +73,60 @@ public function testNonFakedEventGetsProperlyDispatched()
7373
7474 Event::assertNotDispatched (NonImportantEvent::class);
7575 }
76+
77+ public function testNonFakedEventGetsProperlyDispatchedAndReturnsResponses ()
78+ {
79+ Event::fake (NonImportantEvent::class);
80+ Event::listen ('test ' , function () {
81+ // one
82+ });
83+ Event::listen ('test ' , function () {
84+ return 'two ' ;
85+ });
86+ Event::listen ('test ' , function () {
87+ //
88+ });
89+
90+ $ this ->assertEquals ([null , 'two ' , null ], Event::dispatch ('test ' ));
91+
92+ Event::assertNotDispatched (NonImportantEvent::class);
93+ }
94+
95+ public function testNonFakedEventGetsProperlyDispatchedAndCancelsFutureListeners ()
96+ {
97+ Event::fake (NonImportantEvent::class);
98+ Event::listen ('test ' , function () {
99+ // one
100+ });
101+ Event::listen ('test ' , function () {
102+ return false ;
103+ });
104+ Event::listen ('test ' , function () {
105+ $ this ->fail ('should not be called ' );
106+ });
107+
108+ $ this ->assertEquals ([null ], Event::dispatch ('test ' ));
109+
110+ Event::assertNotDispatched (NonImportantEvent::class);
111+ }
112+
113+ public function testNonFakedHaltedEventGetsProperlyDispatchedAndReturnsResponse ()
114+ {
115+ Event::fake (NonImportantEvent::class);
116+ Event::listen ('test ' , function () {
117+ // one
118+ });
119+ Event::listen ('test ' , function () {
120+ return 'two ' ;
121+ });
122+ Event::listen ('test ' , function () {
123+ $ this ->fail ('should not be called ' );
124+ });
125+
126+ $ this ->assertEquals ('two ' , Event::until ('test ' ));
127+
128+ Event::assertNotDispatched (NonImportantEvent::class);
129+ }
76130}
77131
78132class Post extends Model
0 commit comments