3
3
namespace Illuminate \Foundation \Testing \Concerns ;
4
4
5
5
use Mockery ;
6
- use Exception ;
7
6
use Illuminate \Contracts \Bus \Dispatcher as BusDispatcherContract ;
8
7
use Illuminate \Contracts \Events \Dispatcher as EventsDispatcherContract ;
9
8
use Illuminate \Contracts \Notifications \Dispatcher as NotificationDispatcher ;
@@ -57,11 +56,10 @@ public function expectsEvents($events)
57
56
$ this ->beforeApplicationDestroyed (function () use ($ events ) {
58
57
$ fired = $ this ->getFiredEvents ($ events );
59
58
60
- if ($ eventsNotFired = array_diff ($ events , $ fired )) {
61
- throw new Exception (
62
- 'These expected events were not fired: [ ' .implode (', ' , $ eventsNotFired ).'] '
63
- );
64
- }
59
+ $ this ->assertEmpty (
60
+ $ eventsNotFired = array_diff ($ events , $ fired ),
61
+ 'These expected events were not fired: [ ' .implode (', ' , $ eventsNotFired ).'] '
62
+ );
65
63
});
66
64
67
65
return $ this ;
@@ -82,11 +80,10 @@ public function doesntExpectEvents($events)
82
80
$ this ->withoutEvents ();
83
81
84
82
$ this ->beforeApplicationDestroyed (function () use ($ events ) {
85
- if ($ fired = $ this ->getFiredEvents ($ events )) {
86
- throw new Exception (
87
- 'These unexpected events were fired: [ ' .implode (', ' , $ fired ).'] '
88
- );
89
- }
83
+ $ this ->assertEmpty (
84
+ $ fired = $ this ->getFiredEvents ($ events ),
85
+ 'These unexpected events were fired: [ ' .implode (', ' , $ fired ).'] '
86
+ );
90
87
});
91
88
92
89
return $ this ;
@@ -138,11 +135,10 @@ protected function expectsJobs($jobs)
138
135
$ this ->beforeApplicationDestroyed (function () use ($ jobs ) {
139
136
$ dispatched = $ this ->getDispatchedJobs ($ jobs );
140
137
141
- if ($ jobsNotDispatched = array_diff ($ jobs , $ dispatched )) {
142
- throw new Exception (
143
- 'These expected jobs were not dispatched: [ ' .implode (', ' , $ jobsNotDispatched ).'] '
144
- );
145
- }
138
+ $ this ->assertEmpty (
139
+ $ jobsNotDispatched = array_diff ($ jobs , $ dispatched ),
140
+ 'These expected jobs were not dispatched: [ ' .implode (', ' , $ jobsNotDispatched ).'] '
141
+ );
146
142
});
147
143
148
144
return $ this ;
@@ -163,11 +159,10 @@ protected function doesntExpectJobs($jobs)
163
159
$ this ->withoutJobs ();
164
160
165
161
$ this ->beforeApplicationDestroyed (function () use ($ jobs ) {
166
- if ($ dispatched = $ this ->getDispatchedJobs ($ jobs )) {
167
- throw new Exception (
168
- 'These unexpected jobs were dispatched: [ ' .implode (', ' , $ dispatched ).'] '
169
- );
170
- }
162
+ $ this ->assertEmpty (
163
+ $ dispatched = $ this ->getDispatchedJobs ($ jobs ),
164
+ 'These unexpected jobs were dispatched: [ ' .implode (', ' , $ dispatched ).'] '
165
+ );
171
166
});
172
167
173
168
return $ this ;
@@ -280,9 +275,7 @@ protected function expectsNotification($notifiable, $notification)
280
275
}
281
276
}
282
277
283
- throw new Exception (
284
- 'The following expected notification were not dispatched: [ ' .$ notification .'] '
285
- );
278
+ $ this ->fail ('The following expected notification were not dispatched: [ ' .$ notification .'] ' );
286
279
});
287
280
288
281
return $ this ;
0 commit comments