Add permission tests for some accessory api endpoints
This commit is contained in:
parent
549dec9f9e
commit
aa6ab2df60
5 changed files with 89 additions and 0 deletions
19
tests/Feature/Accessories/Api/AccessoryDeleteTest.php
Normal file
19
tests/Feature/Accessories/Api/AccessoryDeleteTest.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 AccessoryDeleteTest 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/AccessoryIndexTest.php
Normal file
16
tests/Feature/Accessories/Api/AccessoryIndexTest.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
19
tests/Feature/Accessories/Api/AccessoryShowTest.php
Normal file
19
tests/Feature/Accessories/Api/AccessoryShowTest.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 AccessoryShowTest 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/AccessoryStoreTest.php
Normal file
16
tests/Feature/Accessories/Api/AccessoryStoreTest.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
19
tests/Feature/Accessories/Api/AccessoryUpdateTest.php
Normal file
19
tests/Feature/Accessories/Api/AccessoryUpdateTest.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 AccessoryUpdateTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testPermissionRequiredToUpdateAccessory()
|
||||||
|
{
|
||||||
|
$accessory = Accessory::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAsForApi(User::factory()->create())
|
||||||
|
->patchJson(route('api.accessories.update', $accessory))
|
||||||
|
->assertForbidden();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue