57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BusProNet\Utility;
|
|
|
|
use App\BusProNet\Utility\BookingUrlUtility;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class BookingUrlUtilityTest extends TestCase
|
|
{
|
|
public function testBuildUsesConfiguredDefaultBaseUrlAsAbsoluteFallback(): void
|
|
{
|
|
$utility = new BookingUrlUtility('https://my.ep-reisen.de');
|
|
|
|
$url = $utility->build(157047, 11606);
|
|
|
|
$this->assertSame(
|
|
'https://my.ep-reisen.de/bookings/create?date_id=11606&hotel_id=157047',
|
|
$url
|
|
);
|
|
}
|
|
|
|
public function testBuildUsesCustomBaseUrlWhenProvided(): void
|
|
{
|
|
$utility = new BookingUrlUtility('https://my.ep-reisen.de');
|
|
|
|
$url = $utility->build(157047, 11606, 'https://my.example.test/');
|
|
|
|
$this->assertSame(
|
|
'https://my.example.test/bookings/create?date_id=11606&hotel_id=157047',
|
|
$url
|
|
);
|
|
}
|
|
|
|
public function testBuildFallsBackToConfiguredDefaultWhenCustomBaseIsBlank(): void
|
|
{
|
|
$utility = new BookingUrlUtility('https://fallback.test');
|
|
|
|
$url = $utility->build(157047, 11606, ' ');
|
|
|
|
$this->assertSame(
|
|
'https://fallback.test/bookings/create?date_id=11606&hotel_id=157047',
|
|
$url
|
|
);
|
|
}
|
|
|
|
public function testBuildReturnsRelativeUrlWhenNoBaseUrlAvailable(): void
|
|
{
|
|
$utility = new BookingUrlUtility('');
|
|
|
|
$url = $utility->build(157047, 11606);
|
|
|
|
$this->assertSame('/bookings/create?date_id=11606&hotel_id=157047', $url);
|
|
}
|
|
}
|