Added another test

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-04 21:52:16 +01:00
parent c570759370
commit 0f43b3f8f9

View file

@ -33,4 +33,22 @@ class CreateAssetModelsTest extends TestCase
$this->assertTrue(AssetModel::where('name', 'Test Model')->exists());
}
public function testUserCannotUseAccessoryCategoryTypeAsAssetModelCategoryType()
{
$response = $this->actingAs(User::factory()->superuser()->create())
->from(route('models.create'))
->post(route('models.store'), [
'name' => 'Test Invalid Model Category',
'category_id' => Category::factory()->forAccessories()->create()->id
]);
$response->assertStatus(302);
$response->assertRedirect(route('models.create'));
$response->assertInvalid(['category_type']);
$response->assertSessionHasErrors(['category_type']);
$this->followRedirects($response)->assertSee(trans('general.error'));
$this->assertFalse(AssetModel::where('name', 'Test Invalid Model Category')->exists());
}
}