修复一些错误

This commit is contained in:
liu
2026-08-14 21:28:55 +08:00
parent 398bb98356
commit 228212f8e3
20 changed files with 489 additions and 100 deletions
+1 -32
View File
@@ -2,7 +2,6 @@
namespace Tests\Feature;
use App\Exports\PurchaseOrderExport;
use App\Models\CustomerLevelModel;
use App\Models\ProductCategoryModel;
use App\Models\ProductModel;
@@ -11,10 +10,9 @@ use App\Models\PurchaseOrderModel;
use App\Models\StoreModel;
use App\Models\StoreOrderModel;
use App\Models\UserModel;
use Maatwebsite\Excel\Facades\Excel;
/**
* 采购单导出(仅 Excel 表格):xlsx Content-Type / 蔬果分类过滤 / type 非法拒绝 /
* 采购单导出(仅 Excel 表格,全品类):xlsx Content-Type /
* 权限拦截 / 中文文件名 RFC 5987 编码
*/
class ExportTest extends ProcurementTestCase
@@ -71,35 +69,6 @@ class ExportTest extends ProcurementTestCase
$this->assertStringContainsString(rawurlencode('采购单'), $disposition);
}
/** 蔬果分类过滤:type=category 仅导出蔬菜/水果顶级分类商品 */
public function test_export_category_filters_to_vegetables(): void
{
$purchase = $this->buildPurchaseWithItems();
$this->actingAsSysUser();
Excel::fake();
$this->get("/purchase/order/{$purchase->id}/export?type=category")->assertOk();
Excel::assertDownloaded(
$purchase->purchase_no . '_采购单.xlsx',
static function (PurchaseOrderExport $export): bool {
$items = $export->collection();
// 仅蔬菜商品一行,肉禽被过滤
return $items->count() === 1;
}
);
}
/** type 参数非法 → 拒绝 */
public function test_export_invalid_type_rejected(): void
{
$purchase = $this->buildPurchaseWithItems();
$this->actingAsSysUser();
$this->get("/purchase/order/{$purchase->id}/export?type=doc")
->assertJsonPath('success', false);
}
/** 采购单不存在 → 拒绝 */
public function test_export_missing_purchase_rejected(): void
{