File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/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
*/
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();
}
}
}
}