value, 'localhost', '/api/endpoint', Port::Web->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'http://localhost/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function serializeHttpUrlWithNonDefaultPort(): void { $url = new Url( Scheme::Http->value, 'localhost', '/api/endpoint', Port::WebSecure->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'http://localhost:443/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function serializeHttpsUrlWithDefaultPort(): void { $url = new Url( Scheme::Https->value, 'localhost', '/api/endpoint', Port::WebSecure->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'https://localhost/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function serializeHttpsUrlWithNonDefaultPort(): void { $url = new Url( Scheme::Https->value, 'localhost', '/api/endpoint', Port::MySql->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'https://localhost:3306/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function testSerializeWebSocketUrlWithDefaultPort(): void { $url = new Url( Scheme::WebSocket->value, 'localhost', '/api/endpoint', Port::Web->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'ws://localhost/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function serializeWebSocketUrlWithNonDefaultPort(): void { $url = new Url( Scheme::Http->value, 'localhost', '/api/endpoint', Port::WebSecure->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'ws://localhost:443/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function serializeWebSocketSecureUrlWithDefaultPort(): void { $url = new Url( Scheme::WebSocketSecure->value, 'localhost', '/api/endpoint', Port::WebSecure->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'wss://localhost/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } public function serializeWebSocketSecureUrlWithNonDefaultPort(): void { $url = new Url( Scheme::WebSocketSecure->value, 'localhost', '/api/endpoint', Port::Web->value, [ 'isActive' => true, 'page' => 1, 'perPage' => 100 ] ); $this->assertSame( 'wss://localhost:80/api/endpoint?isActive=1&page=1&perPage=100', $this->getSerializer()->toString($url) ); } private function getSerializer(): RFC3986 { return new RFC3986(); } }