blessing-skin-server/tests/HttpTest/MiddlewareTest/CheckUserVerifiedTest.php
2019-09-17 23:57:29 +08:00

39 lines
1.1 KiB
PHP

<?php
namespace Tests;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class CheckUserVerifiedTest extends TestCase
{
use DatabaseTransactions;
public function testHandle()
{
$unverified = factory(User::class)->create(['verified' => false]);
option(['require_verification' => false]);
$this->actingAs($unverified)
->get('/skinlib/upload')
->assertSuccessful();
option(['require_verification' => true]);
$this->actingAs($unverified)
->get('/skinlib/upload')
->assertStatus(403)
->assertSee(trans('auth.check.verified'));
$this->actAs('normal')
->get('/skinlib/upload')
->assertSuccessful();
$user = factory(User::class)->create(['verified' => false]);
$this->actingAs($user)->get('/user/oauth/manage')->assertForbidden();
$this->getJson('/oauth/clients')->assertForbidden();
$user->verified = true;
$user->save();
$this->getJson('/oauth/clients')->assertSuccessful();
}
}