summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristian Weiske <[email protected]>2010-11-10 22:18:41 +0100
committerAndrew Dolgov <[email protected]>2010-11-11 09:41:51 +0300
commit444537736be8625a5f2ba15de6c284d91666c011 (patch)
treefcffd5b700d3b30493fe8d7d5cb778e094b28e60 /tests
parent8a7f5767350382531fb5124c09bb33537a5730d2 (diff)
add unit tests for fix_url() and fix a bug I discovered because of them - protocols longer than "http" broke url fixing
Diffstat (limited to 'tests')
-rw-r--r--tests/FunctionsTest.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php
new file mode 100644
index 000000000..61264ac50
--- /dev/null
+++ b/tests/FunctionsTest.php
@@ -0,0 +1,61 @@
+<?php
+require_once dirname(__FILE__) . '/../functions.php';
+/**
+ * Unit tests for functions.php
+ *
+ * @author Christian Weiske <[email protected]>
+ */
+class FunctionsTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * 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/')
+ );
+ }
+}
+
+?> \ No newline at end of file