-
-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathProjectFileChangedListenerTest.php
35 lines (26 loc) · 1.17 KB
/
ProjectFileChangedListenerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
use Illuminate\Contracts\Events\Dispatcher;
use Native\Laravel\Events\App\ProjectFileChanged;
use Native\Laravel\Tests\Fixtures\Fakes\FakePipeline;
use Webmozart\Assert\InvalidArgumentException as WebmozartInvalidArgumentException;
it('listens for the project file changed event and runs configured pipelines', function () {
app()->singleton(FakePipeline::class, fn () => $fake = new FakePipeline);
config(['nativephp.on_php_file_change' => [
FakePipeline::class,
]]);
app(Dispatcher::class)->dispatch(new ProjectFileChanged('some/file.php'));
expect(app(FakePipeline::class)->handled)->toBeTrue();
expect(app(FakePipeline::class)->carry)->toBeInstanceOf(ProjectFileChanged::class);
});
it('rejects nonexistent classes', function () {
config(['nativephp.on_php_file_change' => [
'definitely-not-a-class-fqcn',
]]);
try {
app(Dispatcher::class)->dispatch(new ProjectFileChanged('some/file.php'));
} catch (WebmozartInvalidArgumentException $e) {
expect($e->getMessage())->toBe('Class definitely-not-a-class-fqcn does not exist');
return;
}
$this->fail('Expected an exception to be thrown');
});