TestFuncUrl::TestUrlPlan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
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() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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);
0 ignored issues
show
Deprecated Code introduced by
The function GetSelfUrl() has been deprecated with message: Use Fwlib\Util\HttpUtil::getSelfUrl()

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.

Loading history...
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
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
65