Answers for "php artisan make test"

PHP
0

php artisan make test

Use this command

php artisan make:test BasicTest --unit
Also you can use

php artisan make:test --help
to see available options

You must be create your custom artiasn command

<?php

namespace App\Console;

class TestMakeCommand extends \Illuminate\Foundation\Console\TestMakeCommand
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $signature = 'make:test-custom {name : The name of the class} {--unit : Create a unit test} {--path= : Create a test in path}';

    /**
     * Get the default namespace for the class.
     *
     * @param  string  $rootNamespace
     * @return string
     */
    protected function getDefaultNamespace($rootNamespace)
    {
        $path = $this->option('path');
        if (!is_null($path)) {
            if ($path) {
                return $rootNamespace. '\\' . $path;
            }         

            return $rootNamespace;
        }

        if ($this->option('unit')) {
            return $rootNamespace.'\Unit';
        }

        return $rootNamespace.'\Feature';
    }
}
Register it in kernel

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        TestMakeCommand::class
    ];
    ......  
}
Then you can use

php artisan make:test-custom BasicTest --path=
or

php artisan make:test-custom BasicTest --path=Example
Posted by: Guest on July-13-2021
0

php artisan test

php artisan test --testsuite=Feature --stop-on-failure
Posted by: Guest on September-28-2021

Browse Popular Code Answers by Language