test(back): 套餐表单 back hidden input 仅在 back 非空时渲染(护栏)

This commit is contained in:
萝卜
2026-03-14 01:42:11 +00:00
parent 153c5af8cb
commit c9f04304a5

View File

@@ -0,0 +1,32 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlanFormBackHiddenInputConditionalTest 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_create_form_should_not_render_back_hidden_input_when_back_is_empty(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/plans/create?back=' . urlencode('https://evil.example.com/?x=1'));
$res->assertOk();
// PlanController 会将 unsafe back 清洗为空,因此页面不应渲染 back hidden input
$res->assertDontSee('name="back"', false);
}
}