Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/Console/Commands/Make/MakeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace InterNACHI\Modular\Console\Commands\Make;

use Illuminate\Foundation\Console\EnumMakeCommand;

class MakeEnum extends EnumMakeCommand
{
use Modularize;
}
2 changes: 2 additions & 0 deletions src/Support/ModularizedCommandsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use InterNACHI\Modular\Console\Commands\Make\MakeCommand;
use InterNACHI\Modular\Console\Commands\Make\MakeComponent;
use InterNACHI\Modular\Console\Commands\Make\MakeController;
use InterNACHI\Modular\Console\Commands\Make\MakeEnum;
use InterNACHI\Modular\Console\Commands\Make\MakeEvent;
use InterNACHI\Modular\Console\Commands\Make\MakeException;
use InterNACHI\Modular\Console\Commands\Make\MakeFactory;
Expand Down Expand Up @@ -40,6 +41,7 @@ class ModularizedCommandsServiceProvider extends ServiceProvider
'command.controller.make' => MakeController::class,
'command.console.make' => MakeCommand::class,
'command.channel.make' => MakeChannel::class,
'command.enum.make' => MakeEnum::class,
'command.event.make' => MakeEvent::class,
'command.exception.make' => MakeException::class,
'command.factory.make' => MakeFactory::class,
Expand Down
49 changes: 49 additions & 0 deletions tests/Commands/Make/MakeEnumTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace InterNACHI\Modular\Tests\Commands\Make;

use InterNACHI\Modular\Console\Commands\Make\MakeEnum;
use InterNACHI\Modular\Tests\Concerns\TestsMakeCommands;
use InterNACHI\Modular\Tests\Concerns\WritesToAppFilesystem;
use InterNACHI\Modular\Tests\TestCase;

class MakeEnumTest extends TestCase
{
use WritesToAppFilesystem;
use TestsMakeCommands;

public function test_it_overrides_the_default_command(): void
{
$this->requiresLaravelVersion('11.0.0');

$this->artisan('make:enum', ['--help' => true])
->expectsOutputToContain('--module')
->assertExitCode(0);
}

public function test_it_scaffolds_a_enum_in_the_module_when_module_option_is_set(): void
{
$command = MakeEnum::class;
$arguments = ['name' => 'Status'];
$expected_path = '/src/Status.php';
$expected_substrings = [
'namespace Modules\TestModule',
'enum Status',
];

$this->assertModuleCommandResults($command, $arguments, $expected_path, $expected_substrings);
}

public function test_it_scaffolds_a_enum_in_the_app_when_module_option_is_missing(): void
{
$command = MakeEnum::class;
$arguments = ['name' => 'Status'];
$expected_path = 'app/Status.php';
$expected_substrings = [
'namespace App',
'enum Status',
];

$this->assertBaseCommandResults($command, $arguments, $expected_path, $expected_substrings);
}
}