Files
saasshop/tests/Feature/AdminSiteSubscriptionIndexBackLinkTest.php

41 lines
1.2 KiB
PHP

<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminSiteSubscriptionIndexBackLinkTest 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_should_show_safe_back_link_when_back_is_relative_path(): void
{
$this->loginAsPlatformAdmin();
$this->get('/admin/site-subscriptions?status=activated&back=' . urlencode('/admin/platform-orders?status=pending'))
->assertOk()
->assertSee('返回上一页(保留上下文)')
->assertSee('href="/admin/platform-orders?status=pending"', false);
}
public function test_index_should_not_show_back_link_when_back_is_external_url(): void
{
$this->loginAsPlatformAdmin();
$this->get('/admin/site-subscriptions?back=' . urlencode('https://evil.example.com/'))
->assertOk()
->assertDontSee('返回上一页(保留上下文)');
}
}