Skip to content

Commit

Permalink
refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
norbybaru committed Jun 16, 2024
1 parent 1b92143 commit ef94a51
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions tests/Commands/MakeModelCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ public function test_it_creates_a_model()

public function test_it_creates_a_model_with_migration()
{
$module = 'Content';
$this->artisan(
command: 'module:make:model',
parameters: [
'name' => 'Post',
'--module' => $this->moduleName,
'name' => 'Video',
'--module' => $module,
'--migration' => true,
]
)
->assertExitCode(exitCode: 0);

$this->assertFileExists(filename: $this->getModulePath().'/Models/Post.php');
$this->assertFileExists(filename: $this->getModulePath($module).'/Models/Video.php');
$this->assertDirectoryExists(
directory: $this->getModulePath().'/Database/migration'
directory: $this->getModulePath($module).'/Database/migration/'
);
// TODO: Fix timestamp issue in test
// $this->assertFileExists(filename: $this->getModulePath().'/Database/migration/'.$datetime.'_create_posts_table.php');
Expand All @@ -58,22 +59,23 @@ public function test_it_creates_a_model_with_factory()

public function test_it_creates_a_model_with_migration_and_factory()
{
$module = 'Search';
$this->artisan(
command: 'module:make:model',
parameters: [
'name' => 'Post',
'--module' => $this->moduleName,
'name' => 'Listing',
'--module' => $module,
'--migration' => true,
//'--factory' => true
]
)
->assertExitCode(exitCode: 0);

$this->assertFileExists(
filename: $this->getModulePath().'/Models/Post.php'
filename: $this->getModulePath($module).'/Models/Listing.php'
);
$this->assertDirectoryExists(
directory: $this->getModulePath().'/Database/migration'
directory: $this->getModulePath($module).'/Database/migration/'
);
// TODO: Fix timestamp issue in test
// $this->assertFileExists(
Expand Down
2 changes: 1 addition & 1 deletion tests/MakeCommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public function getModulePath(?string $module = null): string

public function cleanUp(): void
{
$this->app['files']->deleteDirectory($this->getModulePath(module: $this->moduleName));
$this->app['files']->deleteDirectory(base_path(config('modularize.root_path')));
}
}

0 comments on commit ef94a51

Please sign in to comment.