补齐平台订单详情页返回列表兜底测试
This commit is contained in:
@@ -84,4 +84,53 @@ class AdminPlatformOrderShowIndexLinkKeepsContextTest extends TestCase
|
||||
$res3->assertSee('← 返回上一页(保留上下文)');
|
||||
$res3->assertDontSee('返回平台订单列表(保留上下文)');
|
||||
}
|
||||
|
||||
public function test_show_page_should_fall_back_to_platform_order_index_link_with_self_back_when_back_is_unsafe(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$merchant = Merchant::query()->firstOrFail();
|
||||
|
||||
$plan = Plan::query()->create([
|
||||
'code' => 'po_show_index_link_unsafe_back_plan',
|
||||
'name' => '平台订单详情 unsafe back 兜底返回测试套餐',
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 10,
|
||||
'list_price' => 10,
|
||||
'status' => 'active',
|
||||
'sort' => 10,
|
||||
'published_at' => now(),
|
||||
]);
|
||||
|
||||
$order = PlatformOrder::query()->create([
|
||||
'merchant_id' => $merchant->id,
|
||||
'plan_id' => $plan->id,
|
||||
'order_no' => 'PO_SHOW_INDEX_LINK_UNSAFE_BACK_0001',
|
||||
'order_type' => 'new_purchase',
|
||||
'status' => 'pending',
|
||||
'payment_status' => 'unpaid',
|
||||
'plan_name' => $plan->name,
|
||||
'billing_cycle' => $plan->billing_cycle,
|
||||
'period_months' => 1,
|
||||
'quantity' => 1,
|
||||
'payable_amount' => 10,
|
||||
'paid_amount' => 0,
|
||||
'placed_at' => now(),
|
||||
'meta' => [],
|
||||
]);
|
||||
|
||||
$unsafeBack = '/admin/platform-orders?status=pending&back=/admin';
|
||||
|
||||
$res = $this->get('/admin/platform-orders/' . $order->id . '?back=' . urlencode($unsafeBack));
|
||||
$res->assertOk();
|
||||
|
||||
$expectedIndexUrl = '/admin/platform-orders?' . Arr::query([
|
||||
'back' => '/admin/platform-orders/' . $order->id,
|
||||
]);
|
||||
|
||||
$res->assertDontSee('← 返回上一页(保留上下文)');
|
||||
$res->assertSee('返回平台订单列表(保留上下文)');
|
||||
$res->assertSee($expectedIndexUrl, false);
|
||||
$res->assertDontSee('back=' . $unsafeBack, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user