Skip to content

Commit cda8f0b

Browse files
committed
Merge branch '9.x' into 10.x
2 parents cca3198 + c786013 commit cda8f0b

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/SharpInternalServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ protected function clearAssetsPublicDirectoryOnPublish(): void
186186
{
187187
Event::listen(CommandStarting::class, function (CommandStarting $event) {
188188
if ($event->command === 'vendor:publish'
189-
&& $event->input->getOption('tag')
190-
&& in_array('sharp-assets', $event->input->getOption('tag'))
189+
&& $event->input->hasOption('tag')
190+
&& collect($event->input->getOption('tag'))->contains('sharp-assets')
191191
) {
192192
if (File::exists(public_path('vendor/sharp'))) {
193193
File::deleteDirectory(public_path('vendor/sharp'));
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Console\Events\CommandFinished;
4+
use Illuminate\Foundation\Testing\WithConsoleEvents;
5+
use Illuminate\Support\Facades\Event;
6+
7+
uses(WithConsoleEvents::class);
8+
9+
beforeEach(function () {
10+
login();
11+
});
12+
13+
it('allows to update assets', function () {
14+
$commandFinishedEvent = null;
15+
Event::listen(function (CommandFinished $event) use (&$commandFinishedEvent) {
16+
$commandFinishedEvent = $event;
17+
});
18+
19+
$this
20+
->from('/sharp/s-list/person')
21+
->post(route('code16.sharp.update-assets'))
22+
->assertRedirect('/sharp/s-list/person')
23+
->assertSessionHas('sharp_notifications');
24+
25+
expect($commandFinishedEvent)
26+
->toBeInstanceOf(CommandFinished::class)
27+
->and($commandFinishedEvent->command)->toBe('vendor:publish')
28+
->and($commandFinishedEvent->exitCode)->toBe(0);
29+
30+
$notifications = session('sharp_notifications');
31+
$notification = collect($notifications)->first();
32+
expect($notification['title'])->toBe('Assets updated successfully')
33+
->and($notification['level']->value)->toBe('success');
34+
});

0 commit comments

Comments
 (0)