Skip to content

Commit

Permalink
[11.x] Add some test for make:enum when Enums or Enumerations folder …
Browse files Browse the repository at this point in the history
…already exists (#50911)

* feat: add test for enum make when Enums or Enumerations folder exists

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
lmottasin and crynobone authored Apr 4, 2024
1 parent 3002511 commit a98a17b
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/Integration/Generators/EnumMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class EnumMakeCommandTest extends TestCase
{
protected $files = [
'app/IntEnum.php',
'app/StatusEnum.php',
'app/StringEnum.php',
'app/*/OrderStatusEnum.php',
];

public function testItCanGenerateEnumFile()
{
$this->artisan('make:enum', ['name' => 'StatusEnum'])
Expand Down Expand Up @@ -38,4 +45,44 @@ public function testItCanGenerateEnumFileWithInt()
'enum IntEnum: int',
], 'app/IntEnum.php');
}

public function testItCanGenerateEnumFileInEnumsFolder()
{
$enumsFolderPath = app_path('Enums');

/** @var \Illuminate\Filesystem\Filesystem $files */
$files = $this->app['files'];

$files->ensureDirectoryExists($enumsFolderPath);

$this->artisan('make:enum', ['name' => 'OrderStatusEnum'])
->assertExitCode(0);

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

$files->deleteDirectory($enumsFolderPath);
}

public function testItCanGenerateEnumFileInEnumerationsFolder()
{
$enumerationsFolderPath = app_path('Enumerations');

/** @var \Illuminate\Filesystem\Filesystem $files */
$files = $this->app['files'];

$files->ensureDirectoryExists($enumerationsFolderPath);

$this->artisan('make:enum', ['name' => 'OrderStatusEnum'])
->assertExitCode(0);

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

$files->deleteDirectory($enumerationsFolderPath);
}
}

0 comments on commit a98a17b

Please sign in to comment.