修复BUG
This commit is contained in:
@@ -108,6 +108,47 @@ class ProductCostPriceTest extends ProcurementTestCase
|
||||
$this->assertSame('10.00', (string) $product->cost_price);
|
||||
}
|
||||
|
||||
/** 单价单位:不传默认「元/斤」,创建/编辑可修改 */
|
||||
public function test_product_price_unit_default_and_editable(): void
|
||||
{
|
||||
$this->actingAsSysUser();
|
||||
$category = $this->makeCategory();
|
||||
|
||||
// 不传单价单位 → 默认「元/斤」
|
||||
$this->postJson('/product/goods', [
|
||||
'category_id' => $category->id,
|
||||
'name' => '默认单价单位商品',
|
||||
'content' => '测试图文详情',
|
||||
])->assertOk()->assertJsonPath('success', true);
|
||||
$product = ProductModel::where('name', '默认单价单位商品')->first();
|
||||
$this->assertSame('元/斤', $product->price_unit);
|
||||
|
||||
// 创建时指定 + 编辑修改
|
||||
$this->postJson('/product/goods', [
|
||||
'category_id' => $category->id,
|
||||
'name' => '箱装商品',
|
||||
'content' => '测试图文详情',
|
||||
'price_unit' => '元/箱',
|
||||
])->assertOk()->assertJsonPath('success', true);
|
||||
$product2 = ProductModel::where('name', '箱装商品')->first();
|
||||
$this->assertSame('元/箱', $product2->price_unit);
|
||||
|
||||
$this->putJson("/product/goods/{$product2->id}", [
|
||||
'category_id' => $category->id,
|
||||
'name' => '箱装商品',
|
||||
'price_unit' => '元/件',
|
||||
])->assertOk()->assertJsonPath('success', true);
|
||||
$this->assertSame('元/件', $product2->refresh()->price_unit);
|
||||
|
||||
// 超长拒绝
|
||||
$this->postJson('/product/goods', [
|
||||
'category_id' => $category->id,
|
||||
'name' => '异常单价单位商品',
|
||||
'content' => '测试图文详情',
|
||||
'price_unit' => str_repeat('元', 21),
|
||||
])->assertOk()->assertJsonPath('success', false);
|
||||
}
|
||||
|
||||
/** 批量调价-成本价行:更新成本并通知门店;等级售价随上浮比例联动 */
|
||||
public function test_batch_price_cost_row_update(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user