koel/tests/CreatesApplication.php
2017-06-10 14:25:30 +01:00

49 lines
977 B
PHP

<?php
namespace Tests;
use App\Models\User;
use Artisan;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
protected $coverPath;
protected $mediaPath = __DIR__.'/songs';
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$this->coverPath = $app->basePath().'/public/img/covers';
return $app;
}
private function prepareForTests()
{
Artisan::call('migrate');
if (!User::all()->count()) {
Artisan::call('db:seed');
}
if (!file_exists($this->coverPath)) {
mkdir($this->coverPath, 0777, true);
}
}
}