From 10c2d29f7af523f85f880b323215f3b1aa3096b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 22:10:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=BC=BA=E7=AB=99=E7=82=B9=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=B7=B2=E4=BB=98=E6=97=A0=E5=9B=9E=E6=89=A7=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=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 --- ...LinkShouldUseMerchantIndexSelfBackTest.php | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/Feature/AdminMerchantIndexPaidNoReceiptGovernanceLinkShouldUseMerchantIndexSelfBackTest.php diff --git a/tests/Feature/AdminMerchantIndexPaidNoReceiptGovernanceLinkShouldUseMerchantIndexSelfBackTest.php b/tests/Feature/AdminMerchantIndexPaidNoReceiptGovernanceLinkShouldUseMerchantIndexSelfBackTest.php new file mode 100644 index 0000000..4425702 --- /dev/null +++ b/tests/Feature/AdminMerchantIndexPaidNoReceiptGovernanceLinkShouldUseMerchantIndexSelfBackTest.php @@ -0,0 +1,82 @@ +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_merchant_index_self_as_back(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->create([ + 'name' => '站点已付无回执回跳测试站点', + 'slug' => 'merchant-paid-no-receipt-back', + 'plan' => 'pro', + 'status' => 'active', + 'contact_name' => '李四', + 'contact_phone' => '13800138001', + 'contact_email' => 'merchant-paid-no-receipt-back@example.com', + ]); + + $res = $this->get('/admin/merchants?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['merchant_id'] ?? '') !== (string) $merchant->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([ + 'merchant_id' => $merchant->id, + 'payment_status' => 'paid', + 'receipt_status' => 'none', + 'back' => '/admin/merchants', + ]); + + $this->assertSame($expectedUrl, $targetHref); + $this->assertStringNotContainsString(urlencode('/admin/platform-orders?payment_status=paid'), $targetHref); + } +}