From 2a987a5ece7fd7582c4acb9dd89f2c21605ab7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 01:48:13 +0000 Subject: [PATCH] =?UTF-8?q?test(back):=20platform=5Forders/index=20fullUrl?= =?UTF-8?q?WithQuery=20=E9=93=BE=E6=8E=A5=E5=BA=94=E4=BF=9D=E7=95=99=20bac?= =?UTF-8?q?k=EF=BC=88=E6=8A=A4=E6=A0=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rderIndexFullUrlWithQueryKeepsBackTest.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexFullUrlWithQueryKeepsBackTest.php diff --git a/tests/Feature/AdminPlatformOrderIndexFullUrlWithQueryKeepsBackTest.php b/tests/Feature/AdminPlatformOrderIndexFullUrlWithQueryKeepsBackTest.php new file mode 100644 index 0000000..6251550 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexFullUrlWithQueryKeepsBackTest.php @@ -0,0 +1,58 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_summary_links_should_keep_back_query_when_present(): void + { + $this->loginAsPlatformAdmin(); + + $back = '/admin/site-subscriptions?status=activated&keyword=test'; + + $res = $this->get('/admin/platform-orders?back=' . urlencode($back)); + $res->assertOk(); + + $html = $res->getContent(); + + // 选一个稳定存在的 fullUrlWithQuery 链接:支付状态=已支付 + // 断言它仍然携带 back(且 back 原始值中包含 &,因此最终 href 中应包含 back=%2F...%26...) + preg_match_all('/href="([^"]+)"/', $html, $matches); + $hrefs = $matches[1] ?? []; + + $found = false; + foreach ($hrefs as $u) { + if (!str_contains($u, '/admin/platform-orders')) { + continue; + } + if (!str_contains($u, 'payment_status=paid')) { + continue; + } + + $parts = parse_url($u); + parse_str($parts['query'] ?? '', $q); + + if (($q['payment_status'] ?? null) === 'paid' && ($q['back'] ?? null) === $back) { + $found = true; + break; + } + } + + $this->assertTrue($found, '未找到携带 back 的 payment_status=paid 链接(fullUrlWithQuery 可能丢失 back)'); + } +}