2
2
3
3
namespace Codedge \Updater \Tests \Models ;
4
4
5
+ use Codedge \Updater \Events \UpdateFailed ;
6
+ use Codedge \Updater \Events \UpdateSucceeded ;
5
7
use Codedge \Updater \Models \Release ;
6
8
use Codedge \Updater \Models \UpdateExecutor ;
7
- use Codedge \Updater \SourceRepositoryTypes \GithubRepositoryTypes \GithubTagType ;
8
9
use Codedge \Updater \Tests \TestCase ;
9
- use GuzzleHttp \ Client ;
10
+ use Illuminate \ Support \ Facades \ Event ;
10
11
use Illuminate \Support \Facades \File ;
11
12
use org \bovigo \vfs \vfsStream ;
12
13
@@ -52,6 +53,8 @@ public function it_can_run_successfully(): void
52
53
53
54
$ updateExecutor = (new UpdateExecutor ())->setBasePath ($ dir );
54
55
56
+ Event::fake ();
57
+
55
58
$ this ->assertTrue ($ updateExecutor ->run ($ this ->release ));
56
59
$ this ->assertTrue (File::exists ($ dir . '/.some-hidden-file ' ));
57
60
$ this ->assertTrue (File::exists ($ dir . '/outer-file.txt ' ));
@@ -64,6 +67,9 @@ public function it_can_run_successfully(): void
64
67
$ this ->assertFalse (File::exists ($ dir . '/__MACOSX ' ));
65
68
$ this ->assertFalse (File::exists ($ dir . '/release-1.2 ' ));
66
69
$ this ->assertFalse (File::exists ($ dir . '/release-1.2.zip ' ));
70
+
71
+ Event::assertDispatched (UpdateSucceeded::class, 1 );
72
+ Event::assertNotDispatched (UpdateFailed::class);
67
73
}
68
74
69
75
/** @test */
@@ -74,6 +80,11 @@ public function it_can_run_and_fail(): void
74
80
75
81
$ this ->release ->setUpdatePath ($ this ->vfs ->url () . '/updateDirectory ' );
76
82
83
+ Event::fake ();
84
+
77
85
$ this ->assertFalse ((new UpdateExecutor ())->setBasePath ($ this ->vfs ->url () . '/updateDirectory ' )->run ($ this ->release ));
86
+
87
+ Event::assertDispatched (UpdateFailed::class, 1 );
88
+ Event::assertNotDispatched (UpdateSucceeded::class);
78
89
}
79
90
}
0 commit comments