X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=tests%2FFunctionsTest.php;fp=tests%2FFunctionsTest.php;h=0000000000000000000000000000000000000000;hb=c9c4f6b7e3519accdae403346f79a5a03926c9f4;hp=f1bfa74511cda63475e131f245657408ec08c6aa;hpb=4a0500fbc881bf6327a77eaa7298db4fd76c9d08;p=tt-rss.git diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php deleted file mode 100644 index f1bfa745..00000000 --- a/tests/FunctionsTest.php +++ /dev/null @@ -1,245 +0,0 @@ - - */ -class FunctionsTest extends PHPUnit_Framework_TestCase -{ - protected $tmpFile = null; - public function __construct() - { - $this->tmpFile = sys_get_temp_dir() . '/tt-rss-unittest.dat'; - } - - public function tearDown() - { - if (file_exists($this->tmpFile)) { - unlink($this->tmpFile); - } - } - - /** - * Test fix_url with feed:// urls - */ - public function testFixUrlFeed() - { - $this->assertEquals('http://tt-rss.org/', fix_url('feed://tt-rss.org')); - $this->assertEquals('http://tt-rss.org/', fix_url('feed://tt-rss.org/')); - } - - /** - * Test fix_url with non-http protocols - */ - public function testFixUrlProtocols() - { - $this->assertEquals('https://tt-rss.org/', fix_url('https://tt-rss.org')); - $this->assertEquals('ftp://tt-rss.org/', fix_url('ftp://tt-rss.org/')); - $this->assertEquals( - 'reallylongprotocolisthat://tt-rss.org/', - fix_url('reallylongprotocolisthat://tt-rss.org') - ); - } - - /** - * Test fix_url with domain names only - */ - public function testFixUrlDomainOnly() - { - $this->assertEquals('http://tt-rss.org/', fix_url('tt-rss.org')); - $this->assertEquals('http://tt-rss.org/', fix_url('tt-rss.org/')); - $this->assertEquals('http://tt-rss.org/', fix_url('http://tt-rss.org')); - $this->assertEquals('http://tt-rss.org/', fix_url('http://tt-rss.org/')); - } - - /** - * Test fix_url with domain + paths - */ - public function testFixUrlWithPaths() - { - $this->assertEquals('http://tt-rss.org/foo', fix_url('tt-rss.org/foo')); - - $this->assertEquals( - 'http://tt-rss.org/foo/bar/baz', - fix_url('tt-rss.org/foo/bar/baz') - ); - $this->assertEquals( - 'http://tt-rss.org/foo/bar/baz/', - fix_url('tt-rss.org/foo/bar/baz/') - ); - } - - - /** - * Test url_is_html() on html with a doctype - */ - public function testUrlIsHtmlNormalHtmlWithDoctype() - { - file_put_contents( - $this->tmpFile, << - - -HTM - ); - $this->assertTrue(url_is_html($this->tmpFile)); - - file_put_contents( - $this->tmpFile, << - - -HTM - ); - $this->assertTrue(url_is_html($this->tmpFile)); - } - - /** - * Test url_is_html() on html with a doctype and xml header - */ - public function testUrlIsHtmlNormalHtmlWithDoctypeAndXml() - { - file_put_contents( - $this->tmpFile, << - - - -HTM - ); - $this->assertTrue(url_is_html($this->tmpFile)); - } - - /** - * Test url_is_html() on html without a doctype - */ - public function testUrlIsHtmlNormalHtmlWithoutDoctype() - { - file_put_contents( - $this->tmpFile, << - -HTM - ); - $this->assertTrue(url_is_html($this->tmpFile)); - } - - /** - * Test url_is_html() on UPPERCASE HTML - */ - public function testUrlIsHtmlNormalHtmlUppercase() - { - file_put_contents( - $this->tmpFile, << - -HTM - ); - $this->assertTrue(url_is_html($this->tmpFile)); - - file_put_contents( - $this->tmpFile, << - -HTM - ); - $this->assertTrue(url_is_html($this->tmpFile)); - } - - /** - * Test url_is_html() on atom - */ - public function testUrlIsHtmlAtom() - { - file_put_contents( - $this->tmpFile, << - - Christians Tagebuch -HTM - ); - $this->assertFalse(url_is_html($this->tmpFile)); - } - - /** - * Test url_is_html() on RSS - */ - public function testUrlIsHtmlRss() - { - file_put_contents( - $this->tmpFile, << - - - <![CDATA[Planet-PEAR]]> -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/') - ); - } -} - -?> \ No newline at end of file