mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-15 01:54:09 -08:00
283f24b213
Signed-off-by: snipe <snipe@snipe.net>
56 lines
1.7 KiB
PHP
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');
|
|
|
|
}
|
|
|
|
}
|