A free open source IT asset/license management system
Tests
Marcus Moorea0f40c2dfb6e
diff --git a/tests/Feature/Categories/Api/CreateCategoriesTest.php b/tests/Feature/Categories/Api/CreateCategoriesTest.phpindex 2a4a0661a6..92bdb1558b 100644--- a/tests/Feature/Categories/Api/CreateCategoriesTest.php+++ b/tests/Feature/Categories/Api/CreateCategoriesTest.php@@ -11,8 +11,6 @@ use Tests\TestCase;class CreateCategoriesTest extends TestCase{--public function testRequiresPermissionToCreateCategory(){$this->actingAsForApi(User::factory()->create())@@ -28,6 +26,8 @@ class CreateCategoriesTest extends TestCase'eula_text' => 'Test EULA','category_type' => 'accessory','notes' => 'Test Note',+ 'require_acceptance' => true,+ 'alert_on_response' => true,])->assertOk()->assertStatusMessageIs('success')@@ -41,6 +41,8 @@ class CreateCategoriesTest extends TestCase$this->assertEquals('Test EULA', $category->eula_text);$this->assertEquals('Test Note', $category->notes);$this->assertEquals('accessory', $category->category_type);+ $this->assertEquals(1, $category->require_acceptance);+ $this->assertEquals(1, $category->alert_on_response);}public function testCannotCreateCategoryWithoutCategoryType()@@ -81,5 +83,4 @@ class CreateCategoriesTest extends TestCase$this->assertFalse(Category::where('name', 'Test Category')->exists());}-}diff --git a/tests/Feature/Categories/Api/UpdateCategoriesTest.php b/tests/Feature/Categories/Api/UpdateCategoriesTest.phpindex 6d6bc8da10..4823460e67 100644--- a/tests/Feature/Categories/Api/UpdateCategoriesTest.php+++ b/tests/Feature/Categories/Api/UpdateCategoriesTest.php@@ -8,6 +8,40 @@ use Tests\TestCase;class UpdateCategoriesTest extends TestCase{+ public function test_requires_permission_to_update_category()+ {+ $category = Category::factory()->create();++ $this->actingAsForApi(User::factory()->create())+ ->postJson(route('api.categories.update', $category))+ ->assertForbidden();+ }++ public function test_can_update_category()+ {+ $category = Category::factory()->forAssets()->create([+ 'name' => 'Test Category',+ 'require_acceptance' => false,+ 'alert_on_response' => false,+ ]);++ $this->actingAsForApi(User::factory()->superuser()->create())+ ->patchJson(route('api.categories.update', $category), [+ 'name' => 'Test Category Edited',+ 'notes' => 'Test Note Edited',+ 'require_acceptance' => true,+ 'alert_on_response' => true,+ ])+ ->assertOk()+ ->assertStatusMessageIs('success')+ ->assertStatus(200);++ $category->refresh();+ $this->assertEquals('Test Category Edited', $category->name, 'Name was not updated');+ $this->assertEquals('Test Note Edited', $category->notes, 'Note was not updated');+ $this->assertEquals(1, $category->require_acceptance, 'Require acceptance was not updated');+ $this->assertTrue($category->alert_on_response, 'Alert on response was not updated');+ }public function testCanUpdateCategoryViaPatchWithoutCategoryType(){@@ -55,5 +89,4 @@ class UpdateCategoriesTest extends TestCase$this->assertNotEquals('accessory', $category->category_type, 'EULA was not updated');}-}