aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Url/GetUrlSchemeTest.php
diff options
context:
space:
mode:
authorGuillaume Virlet <github@virlet.org>2015-09-02 13:55:39 +0200
committerGuillaume Virlet <github@virlet.org>2015-09-08 22:00:37 +0200
commitef591e7ee21435da9314c5f7f6ea983c6f423898 (patch)
treea58c1bcaab33d42161b23d55c739737526ea17e9 /tests/Url/GetUrlSchemeTest.php
parent0a813cfd7cdf3c81faba8568bf6e2e667aae6f13 (diff)
downloadShaarli-ef591e7ee21435da9314c5f7f6ea983c6f423898.tar.gz
Shaarli-ef591e7ee21435da9314c5f7f6ea983c6f423898.tar.zst
Shaarli-ef591e7ee21435da9314c5f7f6ea983c6f423898.zip
Url: introduce global helper functions for cleanup and scheme detection
Relates to #314 & #326 Additions: - add global `cleanup_url()` and `get_url_scheme()` functions Modifications: - replace `Url` usage in `index.php` by calls to global functions - fix `Url` tests not being run: PHPUnit expects a single test class per file - move classes to separate files
Diffstat (limited to 'tests/Url/GetUrlSchemeTest.php')
-rw-r--r--tests/Url/GetUrlSchemeTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/Url/GetUrlSchemeTest.php b/tests/Url/GetUrlSchemeTest.php
new file mode 100644
index 00000000..72d80b30
--- /dev/null
+++ b/tests/Url/GetUrlSchemeTest.php
@@ -0,0 +1,31 @@
1<?php
2/**
3 * Unitary tests for get_url_scheme()
4 */
5
6require_once 'application/Url.php';
7
8class GetUrlSchemeTest extends PHPUnit_Framework_TestCase
9{
10 /**
11 * Get empty scheme string for empty Url
12 */
13 public function testGetUrlSchemeEmpty()
14 {
15 $this->assertEquals('', get_url_scheme(''));
16 }
17
18 /**
19 * Get normal scheme of Url
20 */
21 public function testGetUrlScheme()
22 {
23 $this->assertEquals('http', get_url_scheme('http://domain.tld:3000'));
24 $this->assertEquals('https', get_url_scheme('https://domain.tld:3000'));
25 $this->assertEquals('http', get_url_scheme('domain.tld'));
26 $this->assertEquals('ssh', get_url_scheme('ssh://domain.tld'));
27 $this->assertEquals('ftp', get_url_scheme('ftp://domain.tld'));
28 $this->assertEquals('git', get_url_scheme('git://domain.tld/push?pull=clone#checkout'));
29 }
30}
31