Skip to content

Commit 6a9a226

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent c9a88b5 commit 6a9a226

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/Feature/Listeners/InstallingWorkbenchTest.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
<?php
22

3+
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
34
use Illuminate\Console\View\Components\Factory as ViewComponent;
5+
use Illuminate\Filesystem\Filesystem;
46
use Laravel\Nova\DevTool\Listeners\InstallingWorkbench;
57
use Mockery as m;
68
use Orchestra\Workbench\Events\InstallStarted;
79
use Symfony\Component\Console\Input\InputInterface;
810
use Symfony\Component\Console\Output\OutputInterface;
911

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+
1032
it('can throw exception if installation with `--basic` option', function () {
11-
$listener = app(InstallingWorkbench::class);
33+
$kernel = m::mock(ConsoleKernel::class);
34+
35+
$listener = new InstallingWorkbench($kernel, new Filesystem());
36+
1237
$event = new InstallStarted(
1338
$input = m::mock(InputInterface::class),
1439
m::mock(OutputInterface::class),
@@ -18,5 +43,8 @@
1843
$input->shouldReceive('hasOption')->with('basic')->andReturnTrue();
1944
$input->shouldReceive('getOption')->with('basic')->andReturnTrue();
2045

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

0 commit comments

Comments
 (0)