diff --git a/tests/Feature/Api/Departments/DepartmentIndexTest.php b/tests/Feature/Api/Departments/DepartmentIndexTest.php index 505e92bd2f..1a3884308f 100644 --- a/tests/Feature/Api/Departments/DepartmentIndexTest.php +++ b/tests/Feature/Api/Departments/DepartmentIndexTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature\Api\Departments; use App\Models\Company; use App\Models\Department; use App\Models\User; +use Illuminate\Routing\Route; use Illuminate\Testing\Fluent\AssertableJson; use Tests\Support\InteractsWithSettings; use Tests\TestCase; @@ -13,6 +14,18 @@ class DepartmentIndexTest extends TestCase { use InteractsWithSettings; + public function testViewingDepartmentIndexRequiresAuthentication() + { + $this->getJson(route('api.departments.index'))->assertRedirect(); + } + + public function testViewingDepartmentIndexRequiresPermission() + { + $this->actingAsForApi(User::factory()->create()) + ->getJson(route('api.departments.index')) + ->assertForbidden(); + } + public function testDepartmentIndexReturnsExpectedDepartments() { Department::factory()->count(3)->create();