first commit
This commit is contained in:
36
tests/Feature/Roles/CountTest.php
Normal file
36
tests/Feature/Roles/CountTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Tests\Feature\Roles;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Tests\Facades\UserFactory;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CountTest extends TestCase
|
||||
{
|
||||
private const URI = 'roles/count';
|
||||
|
||||
private User $admin;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->admin = UserFactory::withTokens()->asAdmin()->create();
|
||||
}
|
||||
|
||||
public function test_count(): void
|
||||
{
|
||||
$response = $this->actingAs($this->admin)->getJson(self::URI);
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJson(['total' => Role::count()]);
|
||||
}
|
||||
|
||||
public function test_unauthorized(): void
|
||||
{
|
||||
$response = $this->getJson(self::URI);
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
}
|
||||
36
tests/Feature/Roles/ListTest.php
Normal file
36
tests/Feature/Roles/ListTest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Tests\Feature\Roles;
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Tests\Facades\UserFactory;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ListTest extends TestCase
|
||||
{
|
||||
private const URI = 'roles/list';
|
||||
|
||||
private User $admin;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->admin = UserFactory::withTokens()->asAdmin()->create();
|
||||
}
|
||||
|
||||
public function test_list(): void
|
||||
{
|
||||
$response = $this->actingAs($this->admin)->getJson(self::URI);
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJson(Role::all()->toArray());
|
||||
}
|
||||
|
||||
public function test_unauthorized(): void
|
||||
{
|
||||
$response = $this->getJson(self::URI);
|
||||
|
||||
$response->assertUnauthorized();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user