From 463d02cf515d389970401ffa85c6e98218467d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 22:13:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=BC=BA=E5=A5=97=E9=A4=90=E9=A1=B5?= =?UTF-8?q?=E5=B7=B2=E4=BB=98=E6=97=A0=E5=9B=9E=E6=89=A7=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E5=9B=9E=E8=B7=B3=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 --- ...anceLinkShouldUsePlanIndexSelfBackTest.php | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/Feature/AdminPlanIndexPaidNoReceiptGovernanceLinkShouldUsePlanIndexSelfBackTest.php diff --git a/tests/Feature/AdminPlanIndexPaidNoReceiptGovernanceLinkShouldUsePlanIndexSelfBackTest.php b/tests/Feature/AdminPlanIndexPaidNoReceiptGovernanceLinkShouldUsePlanIndexSelfBackTest.php new file mode 100644 index 0000000..768caa0 --- /dev/null +++ b/tests/Feature/AdminPlanIndexPaidNoReceiptGovernanceLinkShouldUsePlanIndexSelfBackTest.php @@ -0,0 +1,83 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_paid_no_receipt_governance_link_should_use_plan_index_self_as_back(): void + { + $this->loginAsPlatformAdmin(); + + $plan = Plan::query()->create([ + 'code' => 'plan_index_paid_no_receipt_back', + 'name' => '套餐页已付无回执回跳测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 88, + 'list_price' => 88, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $res = $this->get('/admin/plans?back=' . urlencode('/admin/platform-orders?payment_status=paid')); + $res->assertOk(); + + $html = (string) $res->getContent(); + preg_match_all('/href="([^"]+)"/u', $html, $matches); + $hrefs = array_map('html_entity_decode', $matches[1] ?? []); + + $targetHref = null; + foreach ($hrefs as $candidate) { + if (! str_contains($candidate, '/admin/platform-orders?')) { + continue; + } + + $parts = parse_url($candidate); + parse_str($parts['query'] ?? '', $q); + + if ((string) ($q['plan_id'] ?? '') !== (string) $plan->id) { + continue; + } + + if ((string) ($q['payment_status'] ?? '') !== 'paid') { + continue; + } + + if ((string) ($q['receipt_status'] ?? '') !== 'none') { + continue; + } + + $targetHref = $candidate; + break; + } + + $this->assertNotNull($targetHref, '未找到套餐页目标“已付无回执”入口'); + + $expectedUrl = '/admin/platform-orders?' . Arr::query([ + 'plan_id' => $plan->id, + 'payment_status' => 'paid', + 'receipt_status' => 'none', + 'back' => '/admin/plans', + ]); + + $this->assertSame($expectedUrl, $targetHref); + $this->assertStringNotContainsString(urlencode('/admin/platform-orders?payment_status=paid'), $targetHref); + } +}