|
| 1 | +--TEST-- |
| 2 | +Test that overwriting the URI is not possible |
| 3 | +--EXTENSIONS-- |
| 4 | +uri |
| 5 | +--FILE-- |
| 6 | +<?php |
| 7 | + |
| 8 | +$uri = new Uri\WhatWg\Url('https://example.com'); |
| 9 | +try { |
| 10 | + $uri->__construct('ftp://example.org'); |
| 11 | +} catch (Throwable $e) { |
| 12 | + echo $e::class, ": ", $e->getMessage(), PHP_EOL; |
| 13 | +} |
| 14 | +var_dump($uri); |
| 15 | + |
| 16 | +$uri = new Uri\WhatWg\Url('https://example.com'); |
| 17 | +try { |
| 18 | + $uri->__unserialize([['uri' => 'ftp://example.org'], []]); |
| 19 | +} catch (Throwable $e) { |
| 20 | + echo $e::class, ": ", $e->getMessage(), PHP_EOL; |
| 21 | +} |
| 22 | +var_dump($uri); |
| 23 | + |
| 24 | +$uri = new Uri\Rfc3986\Uri('https://example.com'); |
| 25 | +try { |
| 26 | + $uri->__construct('ftp://example.org'); |
| 27 | +} catch (Throwable $e) { |
| 28 | + echo $e::class, ": ", $e->getMessage(), PHP_EOL; |
| 29 | +} |
| 30 | +var_dump($uri); |
| 31 | + |
| 32 | +$uri = new Uri\Rfc3986\Uri('https://example.com'); |
| 33 | +try { |
| 34 | + $uri->__unserialize([['uri' => 'ftp://example.org'], []]); |
| 35 | +} catch (Throwable $e) { |
| 36 | + echo $e::class, ": ", $e->getMessage(), PHP_EOL; |
| 37 | +} |
| 38 | +var_dump($uri); |
| 39 | + |
| 40 | +?> |
| 41 | +--EXPECTF-- |
| 42 | +Error: Cannot modify readonly object of class Uri\WhatWg\Url |
| 43 | +object(Uri\WhatWg\Url)#%d (8) { |
| 44 | + ["scheme"]=> |
| 45 | + string(5) "https" |
| 46 | + ["username"]=> |
| 47 | + NULL |
| 48 | + ["password"]=> |
| 49 | + NULL |
| 50 | + ["host"]=> |
| 51 | + string(11) "example.com" |
| 52 | + ["port"]=> |
| 53 | + NULL |
| 54 | + ["path"]=> |
| 55 | + string(1) "/" |
| 56 | + ["query"]=> |
| 57 | + NULL |
| 58 | + ["fragment"]=> |
| 59 | + NULL |
| 60 | +} |
| 61 | +Exception: Invalid serialization data for Uri\WhatWg\Url object |
| 62 | +object(Uri\WhatWg\Url)#%d (8) { |
| 63 | + ["scheme"]=> |
| 64 | + string(5) "https" |
| 65 | + ["username"]=> |
| 66 | + NULL |
| 67 | + ["password"]=> |
| 68 | + NULL |
| 69 | + ["host"]=> |
| 70 | + string(11) "example.com" |
| 71 | + ["port"]=> |
| 72 | + NULL |
| 73 | + ["path"]=> |
| 74 | + string(1) "/" |
| 75 | + ["query"]=> |
| 76 | + NULL |
| 77 | + ["fragment"]=> |
| 78 | + NULL |
| 79 | +} |
| 80 | +Error: Cannot modify readonly object of class Uri\Rfc3986\Uri |
| 81 | +object(Uri\Rfc3986\Uri)#%d (8) { |
| 82 | + ["scheme"]=> |
| 83 | + string(5) "https" |
| 84 | + ["username"]=> |
| 85 | + NULL |
| 86 | + ["password"]=> |
| 87 | + NULL |
| 88 | + ["host"]=> |
| 89 | + string(11) "example.com" |
| 90 | + ["port"]=> |
| 91 | + NULL |
| 92 | + ["path"]=> |
| 93 | + string(0) "" |
| 94 | + ["query"]=> |
| 95 | + NULL |
| 96 | + ["fragment"]=> |
| 97 | + NULL |
| 98 | +} |
| 99 | +Exception: Invalid serialization data for Uri\Rfc3986\Uri object |
| 100 | +object(Uri\Rfc3986\Uri)#%d (8) { |
| 101 | + ["scheme"]=> |
| 102 | + string(5) "https" |
| 103 | + ["username"]=> |
| 104 | + NULL |
| 105 | + ["password"]=> |
| 106 | + NULL |
| 107 | + ["host"]=> |
| 108 | + string(11) "example.com" |
| 109 | + ["port"]=> |
| 110 | + NULL |
| 111 | + ["path"]=> |
| 112 | + string(0) "" |
| 113 | + ["query"]=> |
| 114 | + NULL |
| 115 | + ["fragment"]=> |
| 116 | + NULL |
| 117 | +} |
0 commit comments