<?php

namespace Tests\Unit;

use App\Support\BackUrl;
use Illuminate\Support\Arr;
use Tests\TestCase;

class BackUrlWithBackFirstAndFragmentOverridesExistingFragmentTest extends TestCase
{
    public function test_with_back_first_and_fragment_should_override_fragment_in_path_when_fragment_param_is_provided(): void
    {
        $back = '/admin/platform-orders/2';
        $backQuery = Arr::query(['back' => $back]);

        $url = BackUrl::withBackFirstAndFragment('/admin/site-subscriptions/2#old', $back, 'new');

        $this->assertSame('/admin/site-subscriptions/2?' . $backQuery . '#new', $url);
    }
}
