2023-09-20 17:24:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace wishthis\Tests\Api;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use wishthis\URL;
|
|
|
|
|
|
|
|
final class PrettyUrlTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testPrettyUrl(): void
|
|
|
|
{
|
|
|
|
\define('ROOT', \dirname(__DIR__));
|
|
|
|
|
2024-05-29 15:08:43 +00:00
|
|
|
$requestUris = [
|
2023-09-20 17:24:25 +00:00
|
|
|
'//api/database-test',
|
|
|
|
'/api/database-test',
|
|
|
|
'api/database-test',
|
|
|
|
'http://wishthis.online.localhost/index.php/api/database-test',
|
|
|
|
'http://wishthis.online.localhost/index.php//api/database-test',
|
2024-05-29 15:08:43 +00:00
|
|
|
];
|
2023-09-20 17:24:25 +00:00
|
|
|
|
|
|
|
require __DIR__ . '/../src/classes/wishthis/URL.php';
|
|
|
|
|
2024-05-29 15:08:43 +00:00
|
|
|
$expected_GET = [
|
2023-09-20 17:24:25 +00:00
|
|
|
'page' => 'api',
|
|
|
|
'module' => 'database-test',
|
2024-05-29 15:08:43 +00:00
|
|
|
];
|
2023-09-20 17:24:25 +00:00
|
|
|
|
|
|
|
foreach ($requestUris as $requestUri) {
|
|
|
|
$url = new URL($requestUri);
|
|
|
|
|
|
|
|
$this->assertSame($expected_GET, $_GET, $requestUri);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|