diff --git a/tests/Commands/MakeCrudCommandTest.php b/tests/Commands/MakeCrudCommandTest.php index 6e4c0c5..d83fbc6 100644 --- a/tests/Commands/MakeCrudCommandTest.php +++ b/tests/Commands/MakeCrudCommandTest.php @@ -14,9 +14,44 @@ class MakeCrudCommandTest extends TestCase public function crud_files_created_successfully(): void { $this->artisan('crud:make', ['name' => 'Product']) - ->expectsQuestion('Do you want something extra?', 5) - ->assertSuccessful(); + ->expectsQuestion('Do you want something extra?', 0) + ->assertSuccessful() + ->expectsOutput('Crud files successfully generated...'); + // Model + $this->assertFileExists(app_path('Models/Product.php')); + // Migration + $this->migrationExists('create_products_table'); + + // Controller + $this->assertFileExists(app_path('Http/Controllers/ProductController.php')); + + // Requests + $this->assertFileExists(app_path('Http/Requests/ProductStoreRequest.php')); + $this->assertFileExists(app_path('Http/Requests/ProductUpdateRequest.php')); + + // View + $this->assertFileExists(resource_path('views/products/index.blade.php')); + $this->assertFileExists(resource_path('views/products/create.blade.php')); + $this->assertFileExists(resource_path('views/products/edit.blade.php')); + } + + /** + * Check migration file exists. + */ + protected function migrationExists(string $mgr): bool + { + $path = database_path('migrations/'); + $files = scandir($path); + + foreach ($files as &$value) { + $pos = strpos($value, $mgr); + if ($pos !== false) { + return true; + } + } + + return false; } } \ No newline at end of file