Files
saasshop/tests/Feature/AdminPlatformOrderCreateRequireSubscriptionFlagJumpBackShouldIncludeRequireSubscriptionTest.php

42 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 AdminPlatformOrderCreateRequireSubscriptionFlagJumpBackShouldIncludeRequireSubscriptionTest 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_jump_to_subscriptions_link_should_carry_back_with_require_subscription_flag_when_no_query(): void
{
$this->loginAsPlatformAdmin();
// 模拟“校验失败回填后”回到 create 页URL 不带 require_subscription query但 old input 仍有 require_subscription=1
// 通过 withSession 注入 old input
$res = $this->withSession([
'_old_input' => [
'require_subscription' => '1',
],
])->get('/admin/platform-orders/create');
$res->assertOk();
// 关键:跳转订阅管理的链接应带 back且 back 中应包含 require_subscription=1
// 这样用户从订阅管理选中订阅再回来,治理口径不会丢。
$res->assertSee('去订阅管理选择订阅', false);
$res->assertSee('back=%2Fadmin%2Fplatform-orders%2Fcreate%3Frequire_subscription%3D1', false);
}
}