mc-blessing-skin/tests/HttpTest/MiddlewareTest/CheckRoleTest.php

26 lines
560 B
PHP
Raw Permalink Normal View History

2019-09-17 23:57:29 +08:00
<?php
namespace Tests;
use App\Models\User;
2024-01-12 20:41:37 +08:00
class CheckRoleTest extends TestCase
2019-09-17 23:57:29 +08:00
{
public function testHandle()
{
2020-10-14 11:56:34 +08:00
$this->actingAs(User::factory()->create())
2020-01-13 09:25:07 +08:00
->get('/admin')
2019-09-17 23:57:29 +08:00
->assertForbidden();
2020-10-14 11:56:34 +08:00
$this->actingAs(User::factory()->admin()->create())
2020-01-13 09:25:07 +08:00
->get('/admin')
->assertSuccessful();
$this->get('/admin/update')->assertForbidden();
2020-10-14 11:56:34 +08:00
$this->actingAs(User::factory()->superAdmin()->create())
2020-01-13 08:37:57 +08:00
->get('/admin/update')
2019-09-17 23:57:29 +08:00
->assertSuccessful();
}
}