From 053bd5297e28867e6e04cedb3e0b55758a4e5281 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 23 Dec 2024 19:12:53 +0800 Subject: [PATCH] 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 * wip Signed-off-by: Mior Muhammad Zaki --------- Signed-off-by: Mior Muhammad Zaki --- src/Listeners/InstallingWorkbench.php | 10 ++----- .../Listeners/InstallingWorkbenchTest.php | 28 +------------------ 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/Listeners/InstallingWorkbench.php b/src/Listeners/InstallingWorkbench.php index a2dac8f..b0f8872 100644 --- a/src/Listeners/InstallingWorkbench.php +++ b/src/Listeners/InstallingWorkbench.php @@ -2,7 +2,6 @@ namespace Laravel\Nova\DevTool\Listeners; -use Illuminate\Contracts\Console\Kernel as ConsoleKernel; use Illuminate\Filesystem\Filesystem; use Orchestra\Workbench\Events\InstallStarted; use RuntimeException; @@ -12,10 +11,8 @@ class InstallingWorkbench /** * Construct a new event listener. */ - public function __construct( - public ConsoleKernel $kernel, - public Filesystem $files - ) { + public function __construct(public Filesystem $files) + { // } @@ -29,8 +26,5 @@ public function handle(InstallStarted $event) if ($event->isBasicInstallation()) { throw new RuntimeException('Nova Devtool does not support installation with --basic` option'); } - - $this->kernel->call('make:user-model'); - $this->kernel->call('make:user-factory'); } } diff --git a/tests/Feature/Listeners/InstallingWorkbenchTest.php b/tests/Feature/Listeners/InstallingWorkbenchTest.php index c9fda90..74c81a0 100644 --- a/tests/Feature/Listeners/InstallingWorkbenchTest.php +++ b/tests/Feature/Listeners/InstallingWorkbenchTest.php @@ -1,7 +1,6 @@ shouldReceive('hasOption')->with('basic')->andReturnTrue(); - $input->shouldReceive('getOption')->with('basic')->andReturnFalse(); - - $kernel->shouldReceive('call')->with('make:user-model')->once(); - $kernel->shouldReceive('call')->with('make:user-factory')->once(); - - $listener->handle($event); -}); - it('can throw exception if installation with `--basic` option', function () { - $kernel = m::mock(ConsoleKernel::class); - - $listener = new InstallingWorkbench($kernel, new Filesystem); + $listener = new InstallingWorkbench(new Filesystem); $event = new InstallStarted( $input = m::mock(InputInterface::class), @@ -43,8 +20,5 @@ $input->shouldReceive('hasOption')->with('basic')->andReturnTrue(); $input->shouldReceive('getOption')->with('basic')->andReturnTrue(); - $kernel->shouldReceive('call')->with('make:user-model')->never(); - $kernel->shouldReceive('call')->with('make:user-factory')->never(); - $listener->handle($event); })->throws(RuntimeException::class, 'Nova Devtool does not support installation with --basic` option');