. */ namespace App\Tests\Services\InfoProviderSystem\DTOs; use App\Services\InfoProviderSystem\DTOs\FileDTO; use PHPUnit\Framework\TestCase; class FileDTOTest extends TestCase { public static function escapingDataProvider(): \Iterator { //Normal URLs must be unchanged, even if they contain special characters yield ["https://localhost:8000/en/part/1335/edit#attachments", "https://localhost:8000/en/part/1335/edit#attachments"]; yield ["https://localhost:8000/en/part/1335/edit?test=%20%20&sfee_aswer=test-223!*()", "https://localhost:8000/en/part/1335/edit?test=%20%20&sfee_aswer=test-223!*()"]; //Remaining URL unsafe characters must be escaped yield ["test%5Ese", "test^se"]; yield ["test%20se", "test se"]; yield ["test%7Cse", "test|se"]; } /** * @dataProvider escapingDataProvider */ public function testURLEscaping(string $expected, string $input): void { $fileDTO = new FileDTO( $input); self::assertSame($expected, $fileDTO->url); } }