Add permission tests for some accessory api endpoints

This commit is contained in:
Marcus Moore 2024-09-09 14:35:38 -07:00
parent 549dec9f9e
commit aa6ab2df60
No known key found for this signature in database
5 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature\Accessories\Api;
use App\Models\Accessory;
use App\Models\User;
use Tests\TestCase;
class AccessoryDeleteTest extends TestCase
{
public function testPermissionRequiredToDeleteAccessory()
{
$accessory = Accessory::factory()->create();
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.accessories.destroy', $accessory))
->assertForbidden();
}
}

View file

@ -0,0 +1,16 @@
<?php
namespace Tests\Feature\Accessories\Api;
use App\Models\User;
use Tests\TestCase;
class AccessoryIndexTest extends TestCase
{
public function testPermissionRequiredToViewAccessoriesIndex()
{
$this->actingAsForApi(User::factory()->create())
->getJson(route('api.accessories.index'))
->assertForbidden();
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature\Accessories\Api;
use App\Models\Accessory;
use App\Models\User;
use Tests\TestCase;
class AccessoryShowTest extends TestCase
{
public function testPermissionRequiredToShowAccessory()
{
$accessory = Accessory::factory()->create();
$this->actingAsForApi(User::factory()->create())
->getJson(route('api.accessories.show', $accessory))
->assertForbidden();
}
}

View file

@ -0,0 +1,16 @@
<?php
namespace Tests\Feature\Accessories\Api;
use App\Models\User;
use Tests\TestCase;
class AccessoryStoreTest extends TestCase
{
public function testPermissionRequiredToStoreAccessory()
{
$this->actingAsForApi(User::factory()->create())
->postJson(route('api.accessories.store'))
->assertForbidden();
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Tests\Feature\Accessories\Api;
use App\Models\Accessory;
use App\Models\User;
use Tests\TestCase;
class AccessoryUpdateTest extends TestCase
{
public function testPermissionRequiredToUpdateAccessory()
{
$accessory = Accessory::factory()->create();
$this->actingAsForApi(User::factory()->create())
->patchJson(route('api.accessories.update', $accessory))
->assertForbidden();
}
}