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

Commit 5d814c0

Browse files
authored
Merge pull request #1 from coderflexx/v1
Updates & fix tests
2 parents 1a00972 + d02118f commit 5d814c0

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/Console/Concerns/InteractsWithConsoleCommands.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Coderflex\LaraCommand\Console\Concerns;
44

5-
use Symfony\Component\Console\Input\InputArgument;
6-
75
/**
86
* Interact With Console Commands
97
*/
@@ -16,7 +14,12 @@ trait InteractsWithConsoleCommands
1614
*/
1715
public function loopThroughNameArgumentWith(string $command): bool
1816
{
19-
collect($this->argument('name'))->each(function ($name, $key) use ($command) {
17+
/**
18+
* @var array $models
19+
*/
20+
$models = explode(' ', strval($this->argument('name')));
21+
22+
collect($models)->each(function ($name) use ($command) {
2023
$this->line("Generating {$name} class\n");
2124

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

40-
/**
41-
* Get the console command arguments.
42-
*
43-
* @return array
44-
*/
45-
protected function getArguments(): array
46-
{
47-
return [
48-
['name', InputArgument::IS_ARRAY, 'The name of the class'],
49-
];
50-
}
51-
5243
/**
5344
* Get the list of options
5445
*

tests/Commands/ModelMakeCommandTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<?php
22

3+
it('creates a new eloquent single model class', function () {
4+
$this->artisan('laracommand:make-model', [
5+
'name' => 'Category',
6+
])
7+
->assertExitCode(0);
8+
});
9+
10+
it('returns required error if the name was not provided', function () {
11+
$this->artisan('laracommand:make-model', [
12+
'name' => null,
13+
])
14+
->assertExitCode(0);
15+
});
16+
317
it('creates a new eloquent model class', function () {
418
$this->artisan('laracommand:make-model', [
519
'name' => 'Category Product',

0 commit comments

Comments
 (0)