Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Adds Enums folder to make:enum command #50394

Closed
wants to merge 3 commits into from
Closed
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
11 changes: 11 additions & 0 deletions src/Illuminate/Foundation/Console/EnumMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ protected function getStub()
return __DIR__.'/stubs/enum.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\\Enums';
}

/**
* Build the class with the given name.
*
Expand Down
12 changes: 6 additions & 6 deletions tests/Integration/Generators/EnumMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public function testItCanGenerateEnumFile()
->assertExitCode(0);

$this->assertFileContains([
'namespace App;',
'namespace App\Enums;',
'enum StatusEnum',
], 'app/StatusEnum.php');
], 'app/Enums/StatusEnum.php');
}

public function testItCanGenerateEnumFileWithString()
Expand All @@ -23,9 +23,9 @@ public function testItCanGenerateEnumFileWithString()
->assertExitCode(0);

$this->assertFileContains([
'namespace App;',
'namespace App\Enums;',
'enum StringEnum: string',
], 'app/StringEnum.php');
], 'app/Enums/StringEnum.php');
}

public function testItCanGenerateEnumFileWithInt()
Expand All @@ -34,8 +34,8 @@ public function testItCanGenerateEnumFileWithInt()
->assertExitCode(0);

$this->assertFileContains([
'namespace App;',
'namespace App\Enums;',
'enum IntEnum: int',
], 'app/IntEnum.php');
], 'app/Enums/IntEnum.php');
}
}
Loading