Files
saasshop/tests/Feature/AdminDashboardBillingWorkbenchQuickLinksShouldUseBackUrlTest.php

39 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminDashboardBillingWorkbenchQuickLinksShouldUseBackUrlTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_dashboard_quick_links_should_use_back_url_builder_and_not_escape_ampersand(): void
{
$this->loginAsPlatformAdmin();
// 给 dashboard 带一个安全 back模拟从其它页面回到 dashboard 后再点治理入口
$res = $this->get('/admin?back=' . urlencode('/admin/plans'));
$res->assertOk();
// 期望:链接里带 back=%2Fadmin%2Fplans 且 & 不被 escape 成 &amp;
$res->assertSee('href="/admin/platform-orders?payment_status=unpaid&status=pending&back=%2Fadmin%2Fplans"', false);
$res->assertSee('href="/admin/platform-orders?payment_status=paid&status=pending&back=%2Fadmin%2Fplans"', false);
$res->assertSee('href="/admin/platform-orders?syncable_only=1&back=%2Fadmin%2Fplans"', false);
$res->assertSee('href="/admin/platform-orders?sync_status=failed&back=%2Fadmin%2Fplans"', false);
$res->assertDontSee('&amp;back=', false);
}
}