HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/stafa.komma.pro/app/Komma/Kms/ArtisanCommands/RunTests.php
<?php

namespace App\Komma\Kms\ArtisanCommands;

use App\Komma\Kms\QualityAssurance\TestsController;
use Illuminate\Console\Command;

class RunTests extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'kms:test 
                            {flavor? : phpunit, dusk. runs all if omitted} (PHP Bench is currently not supported anymore.)}
                            {--filter= : Filter which tests to run. (see phpunit manual)} 
                            {--group= : Only runs tests from the specified group(s). (see phpunit manual)}
                            {--noprep : add when you don\'t want to prepare the environment}
                            ';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Runs phpunit, dusk tests and phpbench. For kms, and the site.';

    /**
     * @var TestsController $testsController
     */
    protected $testsController;

    /**
     * Create a new command instance.
     */
    public function __construct()
    {
        $this->testsController = app(TestsController::class);
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $flavor = $this->argument('flavor');
        $noprep = $this->option('noprep');

        if(\App::environment() !== 'testing') {
            $this->output->error('Testing cannot be started for dusk tests. Make sure you run the tests using the test environment. E.g. prefix this command with --env=testing');
            return;
        }

        echo "flavor: ".$flavor.PHP_EOL;
        echo "environment: ".\App::environment().PHP_EOL;
        echo "using database: ".config('database.connections.mysql.database').PHP_EOL;
        echo PHP_EOL;

        if(!$noprep) $this->testsController->prepareEnvironment();
        $this->runTests($flavor);

        return;
    }

    /**
     * @param string $type
     * @param null $flavor
     */
    protected function runTests($flavor = null, $type = 'kms')
    {
        switch ($flavor) {
            case 'unit':
            case 'phpunit':
                    $this->testsController->phpunit($type);
                break;
            case 'browser':
            case 'dusk':
                    $this->testsController->dusk($type);
                break;
            case 'benchmark':
            case 'bench':
            case 'phpbench':
                echo 'PHPBench currently isn\'t supported since it is dependant on an old version of phpunit'.PHP_EOL;
//                $this->testsController->phpbench($type);
                break;
            default:
                $this->testsController->phpunit($type);
                $this->testsController->dusk($type);
//                $this->testsController->phpbench($type);
        }
    }
}