snipe-it/tests/Feature/Categories/Api/UpdateCategoriesTest.php
snipe 283f24b213 Derp. Renamed file
Signed-off-by: snipe <snipe@snipe.net>
2024-07-05 08:34:17 +01:00

56 lines
1.7 KiB
PHP

<?php
namespace Tests\Feature\Categories\Api;
use App\Models\Category;
use App\Models\User;
use Tests\TestCase;
class UpdateCategoriesTest extends TestCase
{
public function testCanUpdateCategoryViaPatchWithoutCategoryType()
{
$category = Category::factory()->create();
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.categories.update', $category), [
'name' => 'Test Category',
'eula_text' => 'Test EULA',
])
->assertOk()
->assertStatusMessageIs('success')
->assertStatus(200)
->json();
//dd($response);
$category->refresh();
$this->assertEquals('Test Category', $category->name, 'Name was not updated');
$this->assertEquals('Test EULA', $category->eula_text, 'EULA was not updated');
}
public function testCannotUpdateCategoryViaPatchWithCategoryType()
{
$category = Category::factory()->create();
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.categories.update', $category), [
'name' => 'Test Category',
'eula_text' => 'Test EULA',
'category_type' => 'accessory',
])
->assertOk()
->assertStatusMessageIs('error')
->assertStatus(200)
->json();
$category->refresh();
$this->assertNotEquals('Test Category', $category->name, 'Name was not updated');
$this->assertNotEquals('Test EULA', $category->eula_text, 'EULA was not updated');
$this->assertNotEquals('accessory', $category->category_type, 'EULA was not updated');
}
}