mirror of
https://github.com/snipe/snipe-it.git
synced 2025-12-01 11:30:10 +00:00
Merge pull request #15473 from marcusmoore/testing/accessory_api_tests
Added some permission tests for accessory api endpoints
This commit is contained in:
19
tests/Feature/Accessories/Api/DeleteAccessoryTest.php
Normal file
19
tests/Feature/Accessories/Api/DeleteAccessoryTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
16
tests/Feature/Accessories/Api/IndexAccessoryTest.php
Normal file
16
tests/Feature/Accessories/Api/IndexAccessoryTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
19
tests/Feature/Accessories/Api/ShowAccessoryTest.php
Normal file
19
tests/Feature/Accessories/Api/ShowAccessoryTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
16
tests/Feature/Accessories/Api/StoreAccessoryTest.php
Normal file
16
tests/Feature/Accessories/Api/StoreAccessoryTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
19
tests/Feature/Accessories/Api/UpdateAccessoryTest.php
Normal file
19
tests/Feature/Accessories/Api/UpdateAccessoryTest.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user