Skip to content
This repository was archived by the owner on Nov 11, 2022. It is now read-only.

Updates & fix tests #1

Merged
merged 2 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/Console/Concerns/InteractsWithConsoleCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Coderflex\LaraCommand\Console\Concerns;

use Symfony\Component\Console\Input\InputArgument;

/**
* Interact With Console Commands
*/
Expand All @@ -16,7 +14,12 @@ trait InteractsWithConsoleCommands
*/
public function loopThroughNameArgumentWith(string $command): bool
{
collect($this->argument('name'))->each(function ($name, $key) use ($command) {
/**
* @var array $models
*/
$models = explode(' ', strval($this->argument('name')));

collect($models)->each(function ($name) use ($command) {
$this->line("Generating {$name} class\n");

$this->call(
Expand All @@ -37,18 +40,6 @@ public function loopThroughNameArgumentWith(string $command): bool
return true;
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments(): array
{
return [
['name', InputArgument::IS_ARRAY, 'The name of the class'],
];
}

/**
* Get the list of options
*
Expand Down
14 changes: 14 additions & 0 deletions tests/Commands/ModelMakeCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?php

it('creates a new eloquent single model class', function () {
$this->artisan('laracommand:make-model', [
'name' => 'Category',
])
->assertExitCode(0);
});

it('returns required error if the name was not provided', function () {
$this->artisan('laracommand:make-model', [
'name' => null,
])
->assertExitCode(0);
});

it('creates a new eloquent model class', function () {
$this->artisan('laracommand:make-model', [
'name' => 'Category Product',
Expand Down