From b7d34da73afec0be11fa4b027f2c1c08331e93bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 21:44:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=B7=B2=E4=BB=98=E6=97=A0?= =?UTF-8?q?=E5=9B=9E=E6=89=A7=E6=B2=BB=E7=90=86=E5=85=A5=E5=8F=A3=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=E6=8A=A4=E6=A0=8F=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nceLinksShouldIncludePaidNoReceiptTest.php | 50 ++++++++++++ ...nceLinksShouldIncludePaidNoReceiptTest.php | 81 +++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexLeadLockGovernanceLinksShouldIncludePaidNoReceiptTest.php create mode 100644 tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludePaidNoReceiptTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexLeadLockGovernanceLinksShouldIncludePaidNoReceiptTest.php b/tests/Feature/AdminPlatformOrderIndexLeadLockGovernanceLinksShouldIncludePaidNoReceiptTest.php new file mode 100644 index 0000000..1509b43 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexLeadLockGovernanceLinksShouldIncludePaidNoReceiptTest.php @@ -0,0 +1,50 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_lead_lock_governance_links_should_include_paid_no_receipt(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?lead_id=12&merchant_id=2&plan_id=3&site_subscription_id=4&back=%2Fadmin%2Fplans&syncable_only=1&page=8'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $matched = preg_match('/]+href="([^"]+)"[^>]*>\s*查看已付无回执(该线索)\s*<\/a>/u', $html, $m); + $this->assertSame(1, $matched, '未找到线索治理入口:查看已付无回执(该线索)'); + + $url = $m[1] ?? ''; + $parts = parse_url($url); + parse_str($parts['query'] ?? '', $q); + + $this->assertSame('12', (string) ($q['lead_id'] ?? '')); + $this->assertSame('2', (string) ($q['merchant_id'] ?? '')); + $this->assertSame('3', (string) ($q['plan_id'] ?? '')); + $this->assertSame('4', (string) ($q['site_subscription_id'] ?? '')); + $this->assertSame('/admin/plans', (string) ($q['back'] ?? '')); + + $this->assertSame('paid', (string) ($q['payment_status'] ?? '')); + $this->assertSame('none', (string) ($q['receipt_status'] ?? '')); + + $this->assertArrayNotHasKey('syncable_only', $q); + $this->assertArrayNotHasKey('page', $q); + } +} diff --git a/tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludePaidNoReceiptTest.php b/tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludePaidNoReceiptTest.php new file mode 100644 index 0000000..f5add75 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSubscriptionLockGovernanceLinksShouldIncludePaidNoReceiptTest.php @@ -0,0 +1,81 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_subscription_lock_governance_links_should_include_paid_no_receipt(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $plan = Plan::query()->create([ + 'code' => 'po_index_sub_lock_paid_no_receipt_plan', + 'name' => '平台订单列表订阅锁定治理入口(已付无回执)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'active', + 'source' => 'manual', + 'subscription_no' => 'SS_SUB_LOCK_PAID_NO_RECEIPT_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now(), + 'ends_at' => now()->addMonth(), + ]); + + $res = $this->get('/admin/platform-orders?lead_id=12&merchant_id=' . $merchant->id . '&plan_id=' . $plan->id . '&site_subscription_id=' . $sub->id . '&keyword=abc&page=9&back=%2Fadmin%2Fplans&syncable_only=1'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $matched = preg_match('/]+href="([^"]+)"[^>]*>\s*查看已付无回执(该订阅)\s*<\/a>/u', $html, $m); + $this->assertSame(1, $matched, '未找到订阅治理入口:查看已付无回执(该订阅)'); + + $url = $m[1] ?? ''; + $parts = parse_url($url); + parse_str($parts['query'] ?? '', $q); + + $this->assertSame('12', (string) ($q['lead_id'] ?? '')); + $this->assertSame((string) $merchant->id, (string) ($q['merchant_id'] ?? '')); + $this->assertSame((string) $plan->id, (string) ($q['plan_id'] ?? '')); + $this->assertSame((string) $sub->id, (string) ($q['site_subscription_id'] ?? '')); + $this->assertSame('abc', (string) ($q['keyword'] ?? '')); + $this->assertSame('/admin/plans', (string) ($q['back'] ?? '')); + + $this->assertSame('paid', (string) ($q['payment_status'] ?? '')); + $this->assertSame('none', (string) ($q['receipt_status'] ?? '')); + + $this->assertArrayNotHasKey('syncable_only', $q); + $this->assertArrayNotHasKey('page', $q); + } +}