Merge pull request #15473 from marcusmoore/testing/accessory_api_tests

Added some permission tests for accessory api endpoints
This commit is contained in:
snipe 2024-09-10 11:03:46 +01:00 committed by GitHub
commit 7f3f77dec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 DeleteAccessoryTest 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 IndexAccessoryTest 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 ShowAccessoryTest 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 StoreAccessoryTest 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 UpdateAccessoryTest extends TestCase
{
public function testPermissionRequiredToUpdateAccessory()
{
$accessory = Accessory::factory()->create();
$this->actingAsForApi(User::factory()->create())
->patchJson(route('api.accessories.update', $accessory))
->assertForbidden();
}
}