File: D:/HostingSpaces/pietvanmierlo/stempelbv.nl/app/Komma/Shop/QualityAssurance/TestsController.php
<?php
namespace App\Komma\Shop\QualityAssurance;
use App\Komma\Kms\QualityAssurance\BaseTestController;
/**
* Runs unit / feature / browser tests for the shop
*
* Class TestsController
* @package App\Komma\Shop\
*/
//class TestsController extends BaseTestController implements TestsControllerInterface //TODO fix the interface
class TestsController extends BaseTestController
{
public function __construct()
{
parent::__construct();
$this->baseDirectory = lcfirst(str_replace('\\', '/',__NAMESPACE__)).'/../';
$this->testsFolder = $this->baseDirectory.'Tests/';
$this->screenshotFolder = $this->baseDirectory.'Tests/Browser/screenshots/';
}
/**
* Makes sure the application is in an predictable state (always the same).
*/
public function prepareEnvironment()
{
$this->showBanner('Setting up a predictable shop environment....');
parent::prepareEnvironment();
echo 'Running migrations'.PHP_EOL;
\Artisan::call('migrate');
echo 'Running seeds'.PHP_EOL;
\Artisan::call('db:seed');
echo 'Running shop migrations'.PHP_EOL;
\Artisan::call('shop:migrate');
echo 'Running shop seeds'.PHP_EOL;
\Artisan::call('shop:seed');
echo 'done'.PHP_EOL;
}
/**
* returns true if the controller can run tests, false if not.
*
* @return bool
*/
public function canTest()
{
$isShop = config('app.isShop');
$shopPath = base_path('app/Komma/Shop');
$hasShopInstallation = file_exists($shopPath);
$shopEnabled = ($hasShopInstallation && $isShop);
if(!$shopEnabled) {
$this->echoResult([
'TestsController: The shop is not enabled or present. Please check if the IS_SHOP env value is true and check if the following directory exists: '.$shopPath
]);
}
return $shopEnabled;
}
}