Skip to content

Commit 7d2f47b

Browse files
author
Holger Lösken
committed
Fake events for executor
1 parent fb541fa commit 7d2f47b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/Models/UpdateExecutorTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Codedge\Updater\Tests\Models;
44

5+
use Codedge\Updater\Events\UpdateFailed;
6+
use Codedge\Updater\Events\UpdateSucceeded;
57
use Codedge\Updater\Models\Release;
68
use Codedge\Updater\Models\UpdateExecutor;
7-
use Codedge\Updater\SourceRepositoryTypes\GithubRepositoryTypes\GithubTagType;
89
use Codedge\Updater\Tests\TestCase;
9-
use GuzzleHttp\Client;
10+
use Illuminate\Support\Facades\Event;
1011
use Illuminate\Support\Facades\File;
1112
use org\bovigo\vfs\vfsStream;
1213

@@ -52,6 +53,8 @@ public function it_can_run_successfully(): void
5253

5354
$updateExecutor = (new UpdateExecutor())->setBasePath($dir);
5455

56+
Event::fake();
57+
5558
$this->assertTrue($updateExecutor->run($this->release));
5659
$this->assertTrue(File::exists($dir . '/.some-hidden-file'));
5760
$this->assertTrue(File::exists($dir . '/outer-file.txt'));
@@ -64,6 +67,9 @@ public function it_can_run_successfully(): void
6467
$this->assertFalse(File::exists($dir . '/__MACOSX'));
6568
$this->assertFalse(File::exists($dir . '/release-1.2'));
6669
$this->assertFalse(File::exists($dir . '/release-1.2.zip'));
70+
71+
Event::assertDispatched(UpdateSucceeded::class, 1);
72+
Event::assertNotDispatched(UpdateFailed::class);
6773
}
6874

6975
/** @test */
@@ -74,6 +80,11 @@ public function it_can_run_and_fail(): void
7480

7581
$this->release->setUpdatePath($this->vfs->url() . '/updateDirectory');
7682

83+
Event::fake();
84+
7785
$this->assertFalse((new UpdateExecutor())->setBasePath($this->vfs->url() . '/updateDirectory')->run($this->release));
86+
87+
Event::assertDispatched(UpdateFailed::class, 1);
88+
Event::assertNotDispatched(UpdateSucceeded::class);
7889
}
7990
}

0 commit comments

Comments
 (0)