<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class AdminSiteSubscriptionIndexBackLinkNotEscapedTest 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_index_back_link_should_not_escape_ampersand(): void
    {
        $this->loginAsPlatformAdmin();

        $back = '/admin/platform-orders?status=pending&keyword=test';

        $this->get('/admin/site-subscriptions?back=' . urlencode($back))
            ->assertOk()
            ->assertSee('返回上一页（保留上下文）')
            ->assertSee('href="' . $back . '"', false);
    }
}
