public function testWithFragment() { $uri = new Uri('http://*****:*****@local.example.com:8080/foo?bar=baz#quz'); // $new = $uri->withFragment('qwerty'); $this->assertNotSame($uri, $new); $this->assertSame($new->getFragment(), 'qwerty'); $this->assertSame('http://*****:*****@local.example.com:8080/foo?bar=baz#qwerty', (string) $new); // clean the leading character "#" $new = $uri->withFragment('#foo'); $this->assertSame('foo', $new->getFragment()); }