Skip to content

Commit

Permalink
Merge pull request #15473 from marcusmoore/testing/accessory_api_tests
Browse files Browse the repository at this point in the history
Added some permission tests for accessory api endpoints
  • Loading branch information
snipe authored Sep 10, 2024
2 parents 82e56c6 + 0820dd9 commit 7f3f77d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/Feature/Accessories/Api/DeleteAccessoryTest.php
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions tests/Feature/Accessories/Api/IndexAccessoryTest.php
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions tests/Feature/Accessories/Api/ShowAccessoryTest.php
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions tests/Feature/Accessories/Api/StoreAccessoryTest.php
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 0 deletions tests/Feature/Accessories/Api/UpdateAccessoryTest.php
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 7f3f77d

Please sign in to comment.