X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=tests%2FFunctionsTest.php;fp=tests%2FFunctionsTest.php;h=163e985d0b3fe69cb1df3ab4a40c1375c83ccb9a;hb=24eb4c780f531363e90fe2d8248d50189dcb6b38;hp=61264ac50e53e297514b98f8a130558b69ecb787;hpb=444537736be8625a5f2ba15de6c284d91666c011;p=tt-rss.git diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index 61264ac5..163e985d 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -7,6 +7,19 @@ require_once dirname(__FILE__) . '/../functions.php'; */ 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 */ @@ -56,6 +69,114 @@ class FunctionsTest extends PHPUnit_Framework_TestCase 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)); + } } ?> \ No newline at end of file