Files
saasshop/tests/Unit/BackUrlFragmentInPathTest.php

32 lines
974 B
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\Unit;
use App\Support\BackUrl;
use Illuminate\Support\Arr;
use Tests\TestCase;
class BackUrlFragmentInPathTest extends TestCase
{
public function test_with_back_should_keep_fragment_when_path_contains_hash(): void
{
$back = '/admin/platform-orders/2';
$backQuery = Arr::query(['back' => $back]);
$url = BackUrl::withBack('/admin/site-subscriptions/2#syncable-batch', $back);
$this->assertSame('/admin/site-subscriptions/2?' . $backQuery . '#syncable-batch', $url);
}
public function test_with_back_should_drop_illegal_fragment_when_path_contains_hash(): void
{
$back = '/admin/platform-orders/2';
$backQuery = Arr::query(['back' => $back]);
$url = BackUrl::withBack('/admin/site-subscriptions/2#bad#frag', $back);
// 非法 fragment含 #)应丢弃,避免属性污染
$this->assertSame('/admin/site-subscriptions/2?' . $backQuery, $url);
}
}