mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-12 16:44:08 -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();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanCreateCategoryWithCategoryType()
|
public function testCanCreateCategoryWithValidCategoryType()
|
||||||
{
|
{
|
||||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
->postJson(route('api.categories.store'), [
|
->postJson(route('api.categories.store'), [
|
||||||
|
@ -42,17 +42,40 @@ class CreateCategoriesTest extends TestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotCreateCategoryWithoutCategoryType()
|
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())
|
$this->actingAsForApi(User::factory()->superuser()->create())
|
||||||
->postJson(route('api.categories.store'), [
|
->postJson(route('api.categories.store'), [
|
||||||
'name' => 'Test Category',
|
'name' => 'Test Category',
|
||||||
'eula_text' => 'Test EULA',
|
'eula_text' => 'Test EULA',
|
||||||
|
'category_type' => 'invalid',
|
||||||
])
|
])
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertStatusMessageIs('error')
|
|
||||||
->assertStatus(200)
|
->assertStatus(200)
|
||||||
->json();
|
->assertStatusMessageIs('error')
|
||||||
|
->assertJson([
|
||||||
|
'messages' => [
|
||||||
|
'category_type' => ['The selected category type is invalid.'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
$this->assertFalse(Category::where('name', 'Test Category')->exists());
|
$this->assertFalse(Category::where('name', 'Test Category')->exists());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue