1 | <?php |
||
2 | |||
3 | namespace Ikechukwukalu\Sanctumauthstarter\Console\Commands; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | use Illuminate\Filesystem\Filesystem; |
||
7 | use Illuminate\Support\Str; |
||
8 | use Symfony\Component\Finder\SplFileInfo; |
||
9 | |||
10 | class TestsCommand extends Command |
||
11 | { |
||
12 | /** |
||
13 | * The name and signature of the console command. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $signature = 'sas:tests'; |
||
18 | |||
19 | /** |
||
20 | * The console command description. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $description = 'Scaffold the tests'; |
||
25 | |||
26 | /** |
||
27 | * Execute the console command. |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | public function handle() |
||
32 | { |
||
33 | if (! is_dir($directory = base_path('tests/Feature'))) { |
||
34 | mkdir($directory, 0755, true); |
||
35 | } |
||
36 | |||
37 | $filesystem = new Filesystem; |
||
38 | |||
39 | collect($filesystem->allFiles(__DIR__.'/stubs/Tests')) |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
40 | ->each(function (SplFileInfo $file) use ($filesystem) { |
||
41 | $filesystem->copy( |
||
42 | $file->getPathname(), |
||
43 | base_path('tests/Feature/'.Str::replaceLast('.stub', '.php', $file->getFilename())) |
||
44 | ); |
||
45 | }); |
||
46 | |||
47 | $this->components->info('Tests scaffolding generated successfully.'); |
||
48 | } |
||
49 | } |
||
50 |