|
8 | 8 | use Illuminate\Support\Facades\Artisan; |
9 | 9 | use Tests\TestCase; |
10 | 10 | use Illuminate\Support\Facades\File; |
| 11 | +use Illuminate\Config\Repository; |
| 12 | +use Illuminate\Support\Arr; |
11 | 13 |
|
12 | 14 | class MakeServiceTest extends TestCase |
13 | 15 | { |
@@ -40,6 +42,26 @@ public function test_create_service_custom_path() |
40 | 42 | $this->assertSame(preg_replace('/\s+/', '', File::get(__DIR__.DIRECTORY_SEPARATOR.'resultsOk/service/OtherPostService.php')), preg_replace('/\s+/', '', File::get(app_path('Services2/PostService.php')))); |
41 | 43 | } |
42 | 44 |
|
| 45 | + public function test_create_service_without_config_file() |
| 46 | + { |
| 47 | + app()->instance('config', new class extends Repository { |
| 48 | + public function unset($key) |
| 49 | + { |
| 50 | + Arr::forget($this->items, $key); |
| 51 | + } |
| 52 | + }); |
| 53 | + |
| 54 | + config()->unset('crudgen.paths.service.path'); |
| 55 | + config()->unset('crudgen.paths.service.namespace'); |
| 56 | + |
| 57 | + $serviceExisting = array_map(fn($path) => basename($path), glob(app_path('Services/').'*')); |
| 58 | + $this->assertCount(0, $serviceExisting); |
| 59 | + |
| 60 | + $this->artisan('make:service', ['service_name'=>"PostService"]); |
| 61 | + |
| 62 | + $this->assertSame(preg_replace('/\s+/', '', File::get(__DIR__.DIRECTORY_SEPARATOR.'resultsOk/service/PostService.php')), preg_replace('/\s+/', '', File::get(app_path('Services/PostService.php')))); |
| 63 | + } |
| 64 | + |
43 | 65 | public function tearDown():void |
44 | 66 | { |
45 | 67 | $this->artisan('rm:service', ['service_name'=>"PostService", "--force"=>true]); |
|
0 commit comments