Skip to content

Commit

Permalink
add `check_to_create_files_with_command_crud_make_with_option_factory…
Browse files Browse the repository at this point in the history
…` test
  • Loading branch information
milwad-dev committed Mar 25, 2023
1 parent 86fa37d commit 2c9fa7c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/MakeCrudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ public function check_to_create_files_with_command_crud_make_with_option_reposit
$this->checkAllToRepositoryIsCreatedWithOriginalName();
}

/**
* Test check all files create when user run command 'crud:make' with option factory.
*
* @test
*
* @return void
*/
public function check_to_create_files_with_command_crud_make_with_option_factory()
{
$this->artisan($this->command, ['name' => $this->name])
->expectsQuestion($this->question, 1)
->expectsOutputToContain('created successfully');

$this->checkAllToModelIsCreatedWithOriginalName();
$this->checkAllToMigrationIsCreatedWithOriginalName();
$this->checkAllToControllerIsCreatedWithOriginalName();
$this->checkAllToRequestIsCreatedWithOriginalName();
// $this->checkAllToFactoryIsCreatedWithOriginalName(); TODO
$this->checkAllToViewIsCreatedWithOriginalName($this->name);
}

/**
* Test check all files create when user run command 'crud:make' with ies name.
*
Expand Down
9 changes: 9 additions & 0 deletions tests/Traits/MakeCrudTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,13 @@ private function checkAllToSeederIsCreatedWithOriginalName(): void
$this->assertEquals(1, file_exists($filename));
$this->assertEquals($seeder, basename($filename, '.php'));
}

private function checkAllToFactoryIsCreatedWithOriginalName(): void
{
$factory = ucfirst($this->name).'Factory';
$filename = database_path("factories\\$factory.php");

$this->assertEquals(1, file_exists($filename));
$this->assertEquals($factory, basename($filename, '.php'));
}
}

0 comments on commit 2c9fa7c

Please sign in to comment.