From 7960416aed88da2c1a6719fa8e7d07ae76c5a0b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 13 Mar 2026 14:49:27 +0000 Subject: [PATCH] =?UTF-8?q?test:=20=E5=88=9B=E5=BB=BA=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=A1=A8=E5=8D=95=E9=BB=98=E8=AE=A4=E5=80=BC?= =?UTF-8?q?=E9=A2=84=E9=80=89=E6=8A=A4=E6=A0=8F=EF=BC=88=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E7=BB=AD=E8=B4=B9=E5=85=A5=E5=8F=A3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...formOrderCreateDefaultsPreselectedTest.php | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderCreateDefaultsPreselectedTest.php diff --git a/tests/Feature/AdminPlatformOrderCreateDefaultsPreselectedTest.php b/tests/Feature/AdminPlatformOrderCreateDefaultsPreselectedTest.php new file mode 100644 index 0000000..4e4acb0 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderCreateDefaultsPreselectedTest.php @@ -0,0 +1,80 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_create_form_can_preselect_merchant_plan_and_order_type_from_query_defaults(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'create_defaults_preselect_plan', + 'name' => '创建订单默认值预选测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 100, + 'list_price' => 100, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'activated', + 'source' => 'manual', + 'subscription_no' => 'SUB_CREATE_DEFAULTS_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 100, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addMonth(), + 'activated_at' => now()->subDay(), + ]); + + $url = '/admin/platform-orders/create?merchant_id=' . $merchant->id + . '&plan_id=' . $plan->id + . '&site_subscription_id=' . $sub->id + . '&order_type=renewal' + . '&quantity=2' + . '&discount_amount=3.5' + . '&payment_channel=offline' + . '&remark=' . urlencode('来自订阅:' . $sub->subscription_no); + + $res = $this->get($url); + $res->assertOk(); + + // 预选 merchant/plan/order_type + $res->assertSee('