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('