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