File: D:/HostingSpaces/ZelfVerkopen/zelfverkopen.nl/app/KommaApp/Shop/ArtisanCommands/Tests/RunTests.php
<?php
namespace App\KommaApp\Shop\ArtisanCommands\Tests;
use App\KommaApp\Shop\MigrationsAndSeedsControllerInterface;
use App\KommaApp\Shop\TestsController;
use Illuminate\Console\Command;
class RunTests extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'shop:test
{flavor? : phpunit or dusk. runs both if ommitted}
{filterOrGroup? : Filter or group which tests to run}
{filterOrGroupValue? : Only runs filtered tests or from the specified group(s)}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Runs phpunit and dusk tests.';
/**
* @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;
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();
}
}
return;
}
}