mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2026-01-02 00:09:16 +00:00
add unit tests for rewrite_relative_url and fix a number of bugs in it
This commit is contained in:
committed by
Andrew Dolgov
parent
24eb4c780f
commit
f679105cb2
@@ -177,6 +177,69 @@ HTM
|
||||
);
|
||||
$this->assertFalse(url_is_html($this->tmpFile));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test rewrite_relative_url() with a relative path
|
||||
*/
|
||||
public function testRewriteRelativeUrlRelative()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/foo/bar',
|
||||
rewrite_relative_url('http://tt-rss.org', 'foo/bar')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/foo/bar',
|
||||
rewrite_relative_url('http://tt-rss.org/', 'foo/bar')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/bar',
|
||||
rewrite_relative_url('http://tt-rss.org/foo', 'bar')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/foo/bar',
|
||||
rewrite_relative_url('http://tt-rss.org/foo/', 'bar')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/f/o/bar',
|
||||
rewrite_relative_url('http://tt-rss.org/f/o/o', 'bar')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/f/o/o/bar',
|
||||
rewrite_relative_url('http://tt-rss.org/f/o/o/', 'bar')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test rewrite_relative_url() with an absolute path
|
||||
*/
|
||||
public function testRewriteRelativeUrlAbsolutePath()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/bar/',
|
||||
rewrite_relative_url('http://tt-rss.org/foo/', '/bar/')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/bar/',
|
||||
rewrite_relative_url('http://tt-rss.org/so/what/is/next', '/bar/')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'http://tt-rss.org/bar/',
|
||||
rewrite_relative_url('http://tt-rss.org/so/what/is/next/', '/bar/')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test rewrite_relative_url() with an absolute URL
|
||||
*/
|
||||
public function testRewriteRelativeUrlAbsoluteUrl()
|
||||
{
|
||||
$this->assertEquals(
|
||||
'http://example.org/bar/',
|
||||
rewrite_relative_url('http://tt-rss.org/foo/', 'http://example.org/bar/')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user