blessing-skin-server/tests/BrowserKitTestCase.php
Pig Fang 3cf19d8656
Apply fixes from StyleCI (#11)
This pull request applies code style fixes from an analysis carried out by [StyleCI](https://github.styleci.io).

---

For more information, click [here](https://github.styleci.io/analyses/8wKwbZ).
2019-03-02 22:58:37 +08:00

64 lines
1.3 KiB
PHP

<?php
namespace Tests;
use DB;
use Artisan;
use Tests\Concerns\InteractsWithCache;
use Laravel\BrowserKitTesting\TestCase;
class BrowserKitTestCase extends TestCase
{
use InteractsWithCache;
/**
* 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');
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
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);
}
protected function tearDown(): void
{
$this->beforeApplicationDestroyed(function () {
DB::disconnect();
});
parent::tearDown();
}
}