@@ -10,7 +10,7 @@ class QuickStartCommandTest extends TestCase
1010 protected function setUp (): void
1111 {
1212 parent ::setUp ();
13- $ this -> cleanUp ();
13+
1414 // Ensure api.php exists for tests
1515 if (! File::exists (base_path ('routes/api.php ' ))) {
1616 File::put (base_path ('routes/api.php ' ), '<?php ' );
@@ -27,9 +27,7 @@ protected function cleanUp(): void
2727 {
2828 File::deleteDirectory (app_path ('Rest ' ));
2929 File::deleteDirectory (app_path ('Models ' ));
30- if (File::exists (base_path ('routes/api.php ' ))) {
31- File::put (base_path ('routes/api.php ' ), '<?php ' );
32- }
30+ File::delete (base_path ('routes/api.php ' ));
3331 }
3432
3533 public function test_quick_start_command_creates_necessary_files ()
@@ -53,7 +51,6 @@ public function test_quick_start_command_updates_api_routes()
5351
5452 public function test_quick_start_command_does_not_duplicate_routes ()
5553 {
56- // Run the command twice
5754 $ this ->artisan ('rest:quick-start ' )->assertExitCode (0 );
5855 $ this ->artisan ('rest:quick-start ' )->assertExitCode (0 );
5956
@@ -68,24 +65,18 @@ public function test_quick_start_command_updates_user_model_namespace()
6865 File::makeDirectory (app_path ('Models ' ), 0755 , true );
6966 File::put (app_path ('Models/User.php ' ), '<?php namespace App\Models; class User {} ' );
7067
71- // Run the command
7268 $ this ->artisan ('rest:quick-start ' )->assertExitCode (0 );
7369
74- // Check if the files were created
7570 $ this ->assertFileExists (app_path ('Rest/Resources/UserResource.php ' ));
7671 $ this ->assertFileExists (app_path ('Rest/Controllers/UsersController.php ' ));
7772
7873 $ resourceContent = File::get (app_path ('Rest/Resources/UserResource.php ' ));
7974 $ controllerContent = File::get (app_path ('Rest/Controllers/UsersController.php ' ));
8075
81- // Check for the updated namespace in UserResource.php
8276 $ this ->assertStringContainsString ('\App\Models\User::class ' , $ resourceContent );
8377
84- // Check for the updated namespace in UsersController.php
85- // TODO: We are putting this control in the comment line for now, because UsersController may not have this change made.
86- // $this->assertStringContainsString('\App\Models\User::class', $controllerContent);
78+ $ this ->assertStringContainsString ('\App\Rest\Resources\UserResource::class ' , $ controllerContent );
8779
88- // Additional check Let's check that the User model is used correctly in UserResource
8980 $ this ->assertStringContainsString ('public static $model = \App\Models\User::class; ' , $ resourceContent );
9081 }
9182}
0 commit comments