php artisan make test

Solutions on MaxInterview for php artisan make test by the best coders in the world

showing results for - "php artisan make test"
Giorgio
09 Mar 2019
1Use this command
2
3php artisan make:test BasicTest --unit
4Also you can use
5
6php artisan make:test --help
7to see available options
8
9You must be create your custom artiasn command
10
11<?php
12
13namespace App\Console;
14
15class TestMakeCommand extends \Illuminate\Foundation\Console\TestMakeCommand
16{
17    /**
18     * The console command name.
19     *
20     * @var string
21     */
22    protected $signature = 'make:test-custom {name : The name of the class} {--unit : Create a unit test} {--path= : Create a test in path}';
23
24    /**
25     * Get the default namespace for the class.
26     *
27     * @param  string  $rootNamespace
28     * @return string
29     */
30    protected function getDefaultNamespace($rootNamespace)
31    {
32        $path = $this->option('path');
33        if (!is_null($path)) {
34            if ($path) {
35                return $rootNamespace. '\\' . $path;
36            }         
37
38            return $rootNamespace;
39        }
40
41        if ($this->option('unit')) {
42            return $rootNamespace.'\Unit';
43        }
44
45        return $rootNamespace.'\Feature';
46    }
47}
48Register it in kernel
49
50<?php
51
52namespace App\Console;
53
54use Illuminate\Console\Scheduling\Schedule;
55use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
56
57class Kernel extends ConsoleKernel
58{
59    /**
60     * The Artisan commands provided by your application.
61     *
62     * @var array
63     */
64    protected $commands = [
65        TestMakeCommand::class
66    ];
67    ......  
68}
69Then you can use
70
71php artisan make:test-custom BasicTest --path=
72or
73
74php artisan make:test-custom BasicTest --path=Example