4
4
5
5
use Illuminate \Foundation \Testing \RefreshDatabase ;
6
6
use Illuminate \Support \Facades \Artisan ;
7
+ use Illuminate \Support \Facades \Event ;
7
8
use JTMcC \AtomicDeployments \Events \DeploymentFailed ;
8
9
use JTMcC \AtomicDeployments \Events \DeploymentSuccessful ;
9
10
use JTMcC \AtomicDeployments \Exceptions \InvalidPathException ;
@@ -194,8 +195,9 @@ public function it_cleans_old_build_folders_based_on_build_limit()
194
195
*/
195
196
public function it_dispatches_deployment_successful_event_on_build ()
196
197
{
197
- $ this ->expectsEvents (DeploymentSuccessful::class);
198
198
Artisan::call ('atomic-deployments:deploy --directory=test-dir-1 ' );
199
+
200
+ Event::assertDispatched (DeploymentSuccessful::class);
199
201
}
200
202
201
203
/**
@@ -209,11 +211,11 @@ public function it_dispatches_deployment_successful_event_on_deployment_swap()
209
211
$ deployment = AtomicDeployment::where ('commit_hash ' , 'test-dir-2 ' )->first ()->append ('isCurrentlyDeployed ' )->toArray ();
210
212
$ this ->assertTrue ($ deployment ['isCurrentlyDeployed ' ]);
211
213
212
- $ this ->expectsEvents (DeploymentSuccessful::class);
213
-
214
214
Artisan::call ('atomic-deployments:deploy --hash=test-dir-1 ' );
215
215
$ deployment = AtomicDeployment::where ('commit_hash ' , 'test-dir-1 ' )->first ()->append ('isCurrentlyDeployed ' )->toArray ();
216
216
$ this ->assertTrue ($ deployment ['isCurrentlyDeployed ' ]);
217
+
218
+ Event::assertDispatched (DeploymentSuccessful::class);
217
219
}
218
220
219
221
/**
@@ -225,7 +227,8 @@ public function it_dispatches_deployment_failed_event_on_build_fail()
225
227
$ this ->expectException (InvalidPathException::class);
226
228
$ this ->app ['config ' ]->set ('atomic-deployments.build-path ' , $ this ->buildPath );
227
229
$ this ->app ['config ' ]->set ('atomic-deployments.deployments-path ' , $ this ->buildPath .'/deployments ' );
228
- $ this ->expectsEvents (DeploymentFailed::class);
229
230
Artisan::call ('atomic-deployments:deploy --directory=test-dir-1 ' );
231
+
232
+ Event::assertDispatched (DeploymentFailed::class);
230
233
}
231
234
}
0 commit comments