diff --git a/src/Illuminate/Foundation/Console/EnumMakeCommand.php b/src/Illuminate/Foundation/Console/EnumMakeCommand.php index eeb97d40f142..3ae7a2feee64 100644 --- a/src/Illuminate/Foundation/Console/EnumMakeCommand.php +++ b/src/Illuminate/Foundation/Console/EnumMakeCommand.php @@ -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. * diff --git a/tests/Integration/Generators/EnumMakeCommandTest.php b/tests/Integration/Generators/EnumMakeCommandTest.php index 43feaeba2da5..1a6ed270a5ab 100644 --- a/tests/Integration/Generators/EnumMakeCommandTest.php +++ b/tests/Integration/Generators/EnumMakeCommandTest.php @@ -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() @@ -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() @@ -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'); } }