|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use Illuminate\Contracts\Console\Kernel as ConsoleKernel; |
3 | 4 | use Illuminate\Console\View\Components\Factory as ViewComponent;
|
| 5 | +use Illuminate\Filesystem\Filesystem; |
4 | 6 | use Laravel\Nova\DevTool\Listeners\InstallingWorkbench;
|
5 | 7 | use Mockery as m;
|
6 | 8 | use Orchestra\Workbench\Events\InstallStarted;
|
7 | 9 | use Symfony\Component\Console\Input\InputInterface;
|
8 | 10 | use Symfony\Component\Console\Output\OutputInterface;
|
9 | 11 |
|
| 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 | + |
10 | 32 | 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 | + |
12 | 37 | $event = new InstallStarted(
|
13 | 38 | $input = m::mock(InputInterface::class),
|
14 | 39 | m::mock(OutputInterface::class),
|
|
18 | 43 | $input->shouldReceive('hasOption')->with('basic')->andReturnTrue();
|
19 | 44 | $input->shouldReceive('getOption')->with('basic')->andReturnTrue();
|
20 | 45 |
|
| 46 | + $kernel->shouldReceive('call')->with('make:user-model')->never(); |
| 47 | + $kernel->shouldReceive('call')->with('make:user-factory')->never(); |
| 48 | + |
21 | 49 | $listener->handle($event);
|
22 | 50 | })->throws(RuntimeException::class, 'Nova Devtool does not support installation with --basic` option');
|
0 commit comments