Skip to content

Commit 053bd52

Browse files
authored
fix: avoid workbench:install from stopping at InstallingWorkbench event (#6)
* fix: avoid `workbench:install` from stopping at `InstallingWorkbench` event Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 600753e commit 053bd52

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

src/Listeners/InstallingWorkbench.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Laravel\Nova\DevTool\Listeners;
44

5-
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
65
use Illuminate\Filesystem\Filesystem;
76
use Orchestra\Workbench\Events\InstallStarted;
87
use RuntimeException;
@@ -12,10 +11,8 @@ class InstallingWorkbench
1211
/**
1312
* Construct a new event listener.
1413
*/
15-
public function __construct(
16-
public ConsoleKernel $kernel,
17-
public Filesystem $files
18-
) {
14+
public function __construct(public Filesystem $files)
15+
{
1916
//
2017
}
2118

@@ -29,8 +26,5 @@ public function handle(InstallStarted $event)
2926
if ($event->isBasicInstallation()) {
3027
throw new RuntimeException('Nova Devtool does not support installation with --basic` option');
3128
}
32-
33-
$this->kernel->call('make:user-model');
34-
$this->kernel->call('make:user-factory');
3529
}
3630
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,15 @@
11
<?php
22

33
use Illuminate\Console\View\Components\Factory as ViewComponent;
4-
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
54
use Illuminate\Filesystem\Filesystem;
65
use Laravel\Nova\DevTool\Listeners\InstallingWorkbench;
76
use Mockery as m;
87
use Orchestra\Workbench\Events\InstallStarted;
98
use Symfony\Component\Console\Input\InputInterface;
109
use Symfony\Component\Console\Output\OutputInterface;
1110

12-
it('can make user model and factory if installation without `--basic` option', function () {
13-
$kernel = m::mock(ConsoleKernel::class);
14-
15-
$listener = new InstallingWorkbench($kernel, new Filesystem);
16-
17-
$event = new InstallStarted(
18-
$input = m::mock(InputInterface::class),
19-
m::mock(OutputInterface::class),
20-
m::mock(ViewComponent::class),
21-
);
22-
23-
$input->shouldReceive('hasOption')->with('basic')->andReturnTrue();
24-
$input->shouldReceive('getOption')->with('basic')->andReturnFalse();
25-
26-
$kernel->shouldReceive('call')->with('make:user-model')->once();
27-
$kernel->shouldReceive('call')->with('make:user-factory')->once();
28-
29-
$listener->handle($event);
30-
});
31-
3211
it('can throw exception if installation with `--basic` option', function () {
33-
$kernel = m::mock(ConsoleKernel::class);
34-
35-
$listener = new InstallingWorkbench($kernel, new Filesystem);
12+
$listener = new InstallingWorkbench(new Filesystem);
3613

3714
$event = new InstallStarted(
3815
$input = m::mock(InputInterface::class),
@@ -43,8 +20,5 @@
4320
$input->shouldReceive('hasOption')->with('basic')->andReturnTrue();
4421
$input->shouldReceive('getOption')->with('basic')->andReturnTrue();
4522

46-
$kernel->shouldReceive('call')->with('make:user-model')->never();
47-
$kernel->shouldReceive('call')->with('make:user-factory')->never();
48-
4923
$listener->handle($event);
5024
})->throws(RuntimeException::class, 'Nova Devtool does not support installation with --basic` option');

0 commit comments

Comments
 (0)