Skip to content

A free open source IT asset/license management system

Fixed tests

snipef802ea4d38ee
diff --git a/app/Models/Accessory.php b/app/Models/Accessory.php
index 5a12914437..19beed5a7d 100755
--- a/app/Models/Accessory.php
+++ b/app/Models/Accessory.php
@@ -67,6 +67,7 @@ class Accessory extends SnipeModel
*/
public $rules = [
'name' => 'required|max:255',
+ 'qty' => 'nullable|integer|min:0',
'category_id' => 'required|integer|exists:categories,id',
'company_id' => 'integer|nullable',
'location_id' => 'exists:locations,id|nullable|fmcs_location',
diff --git a/tests/Feature/Accessories/Api/StoreAccessoryTest.php b/tests/Feature/Accessories/Api/StoreAccessoryTest.php
index 53693a5d00..27409f0d87 100644
--- a/tests/Feature/Accessories/Api/StoreAccessoryTest.php
+++ b/tests/Feature/Accessories/Api/StoreAccessoryTest.php
@@ -43,20 +43,7 @@ class StoreAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS
'name' => 'My Awesome Accessory',
]);
}
-
- public function test_validation()
- {
- $this->actingAsForApi(User::factory()->createAccessories()->create())
- ->postJson(route('api.accessories.store'), [
- //
- ])
- ->assertStatusMessageIs('error')
- ->assertMessagesContains([
- 'category_id',
- 'name',
- 'qty',
- ]);
- }
+
public function test_can_store_accessory()
{
diff --git a/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php b/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php
index da2f49ec36..bb63a62a32 100644
--- a/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php
+++ b/tests/Feature/Accessories/Ui/CreateAccessoriesTest.php
@@ -42,7 +42,6 @@ class CreateAccessoriesTest extends TestCase
])
->assertSessionHasErrors([
'name',
- 'qty',
'category_id',
]);
}
diff --git a/tests/Feature/Importing/Api/ImportAccessoriesTest.php b/tests/Feature/Importing/Api/ImportAccessoriesTest.php
index 8843a630d0..5421aae24a 100644
--- a/tests/Feature/Importing/Api/ImportAccessoriesTest.php
+++ b/tests/Feature/Importing/Api/ImportAccessoriesTest.php
@@ -247,7 +247,7 @@ class ImportAccessoriesTest extends ImportDataTestCase implements TestsPermissio
#[Test]
public function when_required_columns_are_missing_in_import_file(): void
{
- $importFileBuilder = ImportFileBuilder::new()->forget(['itemName', 'quantity', 'category']);
+ $importFileBuilder = ImportFileBuilder::new()->forget(['itemName', 'category']);
$import = Import::factory()->accessory()->create(['file_path' => $importFileBuilder->saveToImportsDirectory()]);
$this->actingAsForApi(User::factory()->superuser()->create());
@@ -259,9 +259,8 @@ class ImportAccessoriesTest extends ImportDataTestCase implements TestsPermissio
'messages' => [
'' => [
'Accessory' => [
- 'name' => ['The name field is required.'],
- 'qty' => ['The qty field must be at least 1.'],
'category_id' => ['The category id field is required.'],
+ 'name' => ['The name field is required.'],
],
],
],
@@ -317,7 +316,6 @@ class ImportAccessoriesTest extends ImportDataTestCase implements TestsPermissio
'purchaseDate' => ' ',
'purchaseCost' => '',
'location' => '',
- 'companyName' => '',
'orderNumber' => '',
'category' => '',
'quantity' => '',
@@ -340,7 +338,6 @@ class ImportAccessoriesTest extends ImportDataTestCase implements TestsPermissio
'messages' => [
$importFileBuilder->firstRow()['itemName'] => [
'Accessory' => [
- 'qty' => ['The qty field must be at least 1.'],
'category_id' => ['The category id field is required.'],
],
],