1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Test - url func |
4
|
|
|
* @package fwolflib |
5
|
|
|
* @subpackage func.test |
6
|
|
|
* @copyright Copyright 2009-2010, Fwolf |
7
|
|
|
* @author Fwolf <[email protected]> |
8
|
|
|
* @since 2009-12-04 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
// Define like this, so test can run both under eclipse and web alone. |
12
|
|
|
// {{{ |
13
|
|
|
if (! defined('SIMPLE_TEST')) { |
14
|
|
|
define('SIMPLE_TEST', 'simpletest/'); |
15
|
|
|
require_once(SIMPLE_TEST . 'autorun.php'); |
16
|
|
|
} |
17
|
|
|
// Then set output encoding |
18
|
|
|
//header('Content-Type: text/html; charset=utf-8'); |
19
|
|
|
// }}} |
20
|
|
|
|
21
|
|
|
// Require library define file which need test |
22
|
|
|
require_once('fwolflib/func/request.php'); |
23
|
|
|
require_once('fwolflib/func/url.php'); |
24
|
|
|
|
25
|
|
|
class TestFuncUrl extends UnitTestCase { |
26
|
|
|
|
27
|
|
View Code Duplication |
function TestSetUrlParam() { |
28
|
|
|
$url = 'http://www.domain.tld/?a=1&b=2&'; |
29
|
|
|
|
30
|
|
|
$url1 = SetUrlParam($url, 'a', 2); |
31
|
|
|
$this->assertEqual($url1, 'http://www.domain.tld/?a=2&b=2'); |
32
|
|
|
|
33
|
|
|
$url1 = SetUrlParam($url, 'b', 3); |
34
|
|
|
$this->assertEqual($url1, 'http://www.domain.tld/?a=1&b=3'); |
35
|
|
|
|
36
|
|
|
$url1 = SetUrlParam($url, 'c'); |
37
|
|
|
$this->assertEqual($url1, 'http://www.domain.tld/?a=1&b=2&c='); |
38
|
|
|
|
39
|
|
|
} // end of func TestSetUrlParam |
40
|
|
|
|
41
|
|
|
function TestUrlPlan() { |
42
|
|
|
$url = 'http://www.google.com/?a=https://something'; |
43
|
|
|
$this->assertEqual(UrlPlan($url), 'http'); |
44
|
|
|
|
45
|
|
|
$url = 'https://www.fwolf.com/'; |
46
|
|
|
$this->assertEqual(UrlPlan($url), 'https'); |
47
|
|
|
|
48
|
|
|
$url = 'ftp://domain.tld/'; |
49
|
|
|
$this->assertEqual(UrlPlan($url), 'ftp'); |
50
|
|
|
} // end of func TestUrlPlan |
51
|
|
|
|
52
|
|
|
} // end of class TestFuncUrl |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
// Change output charset in this way. |
56
|
|
|
// {{{ |
57
|
|
|
$s_url = GetSelfUrl(false); |
|
|
|
|
58
|
|
|
$s_url = substr($s_url, strrpos($s_url, '/') + 1); |
59
|
|
|
if ('url.test.php' == $s_url) { |
60
|
|
|
$test = new TestFuncUrl(); |
61
|
|
|
$test->run(new HtmlReporter('utf-8')); |
62
|
|
|
} |
63
|
|
|
// }}} |
64
|
|
|
?> |
65
|
|
|
|
This function has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.