mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
98522a5cce
[ci skip] [skip ci]
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Artisan;
|
|
use Laravel\BrowserKitTesting\TestCase;
|
|
|
|
class BrowserKitTestCase extends TestCase
|
|
{
|
|
/**
|
|
* 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(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
|
|
|
Artisan::call('migrate:refresh');
|
|
|
|
$files = $app->make('files');
|
|
if (! $files->exists(storage_path('install.lock'))) {
|
|
$files->put(storage_path('install.lock'), '');
|
|
}
|
|
|
|
return $app;
|
|
}
|
|
|
|
/**
|
|
* @param \App\Models\User|string $role
|
|
* @return $this
|
|
*/
|
|
public function actAs($role)
|
|
{
|
|
if (is_string($role)) {
|
|
if ($role == 'normal') {
|
|
$role = factory(\App\Models\User::class)->create();
|
|
} else {
|
|
$role = factory(\App\Models\User::class, $role)->create();
|
|
}
|
|
}
|
|
|
|
return $this->actingAs($role);
|
|
}
|
|
}
|