@@ -240,6 +240,44 @@ public function testSetSchemeSetsValue()
240240 $ this ->assertSame ($ expected , (string ) $ uri );
241241 }
242242
243+ public function testWithScheme ()
244+ {
245+ $ url = 'example.com ' ;
246+ $ uri = new URI ('http:// ' . $ url );
247+
248+ $ new = $ uri ->withScheme ('x ' );
249+
250+ $ this ->assertSame ('x:// ' . $ url , (string ) $ new );
251+ $ this ->assertSame ('http:// ' . $ url , (string ) $ uri );
252+ }
253+
254+ public function testWithSchemeSetsHttps ()
255+ {
256+ $ url = 'http://example.com/path ' ;
257+ $ uri = new URI ($ url );
258+
259+ $ new = $ uri ->withScheme ('https ' );
260+
261+ $ this ->assertSame ('https ' , $ new ->getScheme ());
262+ $ this ->assertSame ('http ' , $ uri ->getScheme ());
263+
264+ $ expected = 'https://example.com/path ' ;
265+ $ this ->assertSame ($ expected , (string ) $ new );
266+ $ expected = 'http://example.com/path ' ;
267+ $ this ->assertSame ($ expected , (string ) $ uri );
268+ }
269+
270+ public function testWithSchemeSetsEmpty ()
271+ {
272+ $ url = 'example.com ' ;
273+ $ uri = new URI ('http:// ' . $ url );
274+
275+ $ new = $ uri ->withScheme ('' );
276+
277+ $ this ->assertSame ($ url , (string ) $ new );
278+ $ this ->assertSame ('http:// ' . $ url , (string ) $ uri );
279+ }
280+
243281 public function testSetUserInfoSetsValue ()
244282 {
245283 $ url = 'http://example.com/path ' ;
0 commit comments