You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.3 KiB

<?php
class TikiLib_UriMergeTest extends PHPUnit\Framework\TestCase
{
public function testFullReplace(): void
{
$this->assertEquals('http://www.example.com/', $this->merge('http://example.com/foo/bar?x=y', 'http://www.example.com'));
}
public function testAbsolutePath(): void
{
$this->assertEquals('http://example.com/foo/baz', $this->merge('http://example.com/foo/bar?x=y', '/foo/baz'));
}
public function testRelativePath(): void
{
$this->assertEquals('http://example.com/foo/baz', $this->merge('http://example.com/foo/bar?x=y', 'baz'));
}
public function testShortRelativePath(): void
{
$this->assertEquals('http://example.com/baz', $this->merge('http://example.com/foo', 'baz'));
}
public function testNoCurrentPath(): void
{
$this->assertEquals('http://example.com/foo/baz', $this->merge('http://example.com', 'foo/baz'));
}
public function testWithQueryString(): void
{
$this->assertEquals('http://example.com/foo/baz?y=x&a=b', $this->merge('http://example.com/foo/bar?x=y', 'baz?y=x&a=b'));
}
private function merge($first, $last)
{
return TikiLib::lib('tiki')->http_get_uri(new Laminas\Uri\Http($first), $last)->toString();
}
}