blessing-skin-server/tests/TestCase.php

44 lines
1.0 KiB
PHP
Raw Normal View History

2017-10-26 23:24:33 +08:00
<?php
class TestCase extends Illuminate\Foundation\Testing\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');
2017-10-26 23:24:33 +08:00
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->withSession(['uid' => $role->uid, 'token' => $role->getToken()]);
}
2017-10-26 23:24:33 +08:00
}