diff --git a/src/SharpInternalServiceProvider.php b/src/SharpInternalServiceProvider.php index 6cec39cb6..76ff20287 100644 --- a/src/SharpInternalServiceProvider.php +++ b/src/SharpInternalServiceProvider.php @@ -198,8 +198,8 @@ protected function clearAssetsPublicDirectoryOnPublish(): void { Event::listen(CommandStarting::class, function (CommandStarting $event) { if ($event->command === 'vendor:publish' - && $event->input->getOption('tag') - && in_array('sharp-assets', $event->input->getOption('tag')) + && $event->input->hasOption('tag') + && collect($event->input->getOption('tag'))->contains('sharp-assets') ) { if (File::exists(public_path('vendor/sharp'))) { File::deleteDirectory(public_path('vendor/sharp')); diff --git a/tests/Http/UpdateAssetsControllerTest.php b/tests/Http/UpdateAssetsControllerTest.php new file mode 100644 index 000000000..f423cacf1 --- /dev/null +++ b/tests/Http/UpdateAssetsControllerTest.php @@ -0,0 +1,34 @@ +from('/sharp/s-list/person') + ->post(route('code16.sharp.update-assets')) + ->assertRedirect('/sharp/s-list/person') + ->assertSessionHas('sharp_notifications'); + + expect($commandFinishedEvent) + ->toBeInstanceOf(CommandFinished::class) + ->and($commandFinishedEvent->command)->toBe('vendor:publish') + ->and($commandFinishedEvent->exitCode)->toBe(0); + + $notifications = session('sharp_notifications'); + $notification = collect($notifications)->first(); + expect($notification['title'])->toBe('Assets updated successfully') + ->and($notification['level']->value)->toBe('success'); +});