mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Fleshed out tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
efb9d107cf
commit
a0914ccb28
|
@ -20,7 +20,7 @@ class CreateCategoriesTest extends TestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testCanCreateCategoryWithCategoryType()
|
||||
public function testCanCreateCategoryWithValidCategoryType()
|
||||
{
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.categories.store'), [
|
||||
|
@ -42,17 +42,40 @@ class CreateCategoriesTest extends TestCase
|
|||
}
|
||||
|
||||
public function testCannotCreateCategoryWithoutCategoryType()
|
||||
{
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.categories.store'), [
|
||||
'name' => 'Test Category',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatus(200)
|
||||
->assertStatusMessageIs('error')
|
||||
->assertJson([
|
||||
'messages' => [
|
||||
'category_type' => ['The category type field is required.'],
|
||||
],
|
||||
]);
|
||||
$this->assertFalse(Category::where('name', 'Test Category')->exists());
|
||||
|
||||
}
|
||||
|
||||
public function testCannotCreateCategoryWithInvalidCategoryType()
|
||||
{
|
||||
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->postJson(route('api.categories.store'), [
|
||||
'name' => 'Test Category',
|
||||
'eula_text' => 'Test EULA',
|
||||
'category_type' => 'invalid',
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('error')
|
||||
->assertStatus(200)
|
||||
->json();
|
||||
|
||||
->assertStatusMessageIs('error')
|
||||
->assertJson([
|
||||
'messages' => [
|
||||
'category_type' => ['The selected category type is invalid.'],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertFalse(Category::where('name', 'Test Category')->exists());
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue