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/Neopoints/momsecurity.be/app/Komma/ArtisanCommands/RunTests.php
<?php

namespace App\Komma\ArtisanCommands;

use App\Komma\QualityAssurance\TestsController;
use App\Komma\Shop\MigrationsAndSeedsControllerInterface;
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, phpbench. runs all if ommitted} 
                            {filterOrGroup? : Verbatim the string "filter" or "group" to only run tests which match the filter or group} 
                            {filterOrGroupValue? : The name of the group to test or the value for the filter}';

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

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

    /**
     * Create a new command instance.
     *
     * @param TestsController $controller
     */
    public function __construct(TestsController $controller)
    {
        parent::__construct();

        $this->testsController = $controller;
    }

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

        echo "flavor: ".$flavor.PHP_EOL;
        echo "filterOrGroup: ".$filterOrGroup.PHP_EOL;
        echo "value: ".$filterOrGroupValue.PHP_EOL;

        switch ($flavor) {
            case 'unit':
            case 'phpunit':
                switch($filterOrGroup) {
                    case 'group':
                        $this->testsController->phpunit("--group", $filterOrGroupValue);
                        break;
                    case 'filter':
                        $this->testsController->phpunit("--filter", $filterOrGroupValue);
                        break;
                    default:
                        $this->testsController->phpunit();
                }
                break;
            case 'browser':
            case 'dusk':
                switch($filterOrGroup) {
                    case 'group':
                        $this->testsController->dusk("--group", $filterOrGroupValue);
                        break;
                    case 'filter':
                        $this->testsController->dusk("--filter", $filterOrGroupValue);
                        break;
                    default:
                        $this->testsController->dusk();
                }
                break;
            case 'benchmark':
            case 'bench':
            case 'phpbench':
                switch($filterOrGroup) {
                    case 'group':
                        $this->testsController->phpbench("--group", $filterOrGroupValue);
                        break;
                    case 'filter':
                        $this->testsController->phpbench("--filter", $filterOrGroupValue);
                        break;
                    default:
                        $this->testsController->phpbench();
                }
                break;
            default:
                switch($filterOrGroup) {
                    case 'group':
                        $this->testsController->phpunit("--group", $filterOrGroupValue);
                        break;
                    case 'filter':
                        $this->testsController->phpunit("--filter", $filterOrGroupValue);
                        break;
                    default:
                        $this->testsController->phpunit();
                };

                switch($filterOrGroup) {
                    case 'group':
                        $this->testsController->dusk("--group", $filterOrGroupValue);
                        break;
                    case 'filter':
                        $this->testsController->dusk("--filter", $filterOrGroupValue);
                        break;
                    default:
                        $this->testsController->dusk();
                }

                switch($filterOrGroup) {
                    case 'group':
                        $this->testsController->phpbench("--group", $filterOrGroupValue);
                        break;
                    case 'filter':
                        $this->testsController->phpbench("--filter", $filterOrGroupValue);
                        break;
                    default:
                        $this->testsController->phpbench();
                }
        }

        return;
    }
}