Fixes for tests

This commit is contained in:
David Bomba 2024-10-02 10:59:14 +10:00
parent 002e4a7aab
commit 105b5c967b
2 changed files with 30 additions and 0 deletions

View File

@ -52,6 +52,11 @@ class StoreProductRequest extends Request
$rules['stock_notification_threshold'] = 'sometimes|numeric';
$rules['stock_notification'] = 'sometimes|bool';
$rules['tax_rate1'] = 'bail|sometimes|numeric';
$rules['tax_rate2'] = 'bail|sometimes|numeric';
$rules['tax_rate3'] = 'bail|sometimes|numeric';
return $rules;
}
@ -67,6 +72,10 @@ class StoreProductRequest extends Request
$input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']);
}
$input['tax_name1'] = $input['tax_name1'] ?? '';
$input['tax_name2'] = $input['tax_name2'] ?? '';
$input['tax_name3'] = $input['tax_name3'] ?? '';
$this->replace($input);
}
}

View File

@ -53,6 +53,27 @@ class ProductTest extends TestCase
}
public function testRequiredFields()
{
$product = [
'cost' => 10,
'vendor_id' => $this->vendor->hashed_id
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/products', $product)
->assertStatus(200);
$arr = $response->json();
$p = Product::find($this->decodePrimaryKey($arr['data']['id']));
$this->assertNull($p->vendor_id);
}
public function testProductCostMigration()
{
$items = [];