Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 9, 2023
1 parent aea8686 commit aac18ef
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tests/Unit/NewProjectCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Illuminate\Contracts\Events\Dispatcher;

test('can create new project', function () {
$app = Mockery::mock(Application::class)->makePartial();

Process::swap(new Factory());

Process::preventStrayProcesses();
Expand All @@ -15,6 +17,27 @@

Process::shouldReceive('run')->once()->withArgs([null, Mockery::type(Closure::class)])->andReturnSelf();

$kernel = new ConsoleKernel(new Application(__DIR__.'/../..'), Mockery::mock(Dispatcher::class));
$kernel->call('new', ['name' => 'test-project']);
$command = new \App\Commands\NewProjectCommand();
$input = Mockery::mock(\Symfony\Component\Console\Input\InputInterface::class);
$input->makePartial();
$input->shouldReceive('getOption')->andReturn(false);
$input->shouldReceive('getArgument')->andReturn('test-project');
$outputInterface = Mockery::mock(\Symfony\Component\Console\Output\OutputInterface::class);
$outputInterface->makePartial();
$outputInterface->shouldReceive('getVerbosity')->andReturn(0);
$outputInterface->shouldReceive('write');
$outputInterface->shouldReceive('writeln');
$formatter = Mockery::mock(\Symfony\Component\Console\Formatter\OutputFormatterInterface::class);
$formatter->makePartial();
$formatter->shouldReceive('setDecorated');
$outputInterface->shouldReceive('getFormatter')->andReturn($formatter);

$output = Mockery::mock(\Illuminate\Console\OutputStyle::class, [$input, $outputInterface])->makePartial();
$output->makePartial();

$command->setLaravel($app);
$command->setOutput($output);
$command->setInput($input);

$command->handle();
});

0 comments on commit aac18ef

Please sign in to comment.