TestFuncRequest::TestGetParam()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 22
rs 9.568
c 0
b 0
f 0
1
<?php
2
/**
3
 * Test - request function
4
 * @package     fwolflib
5
 * @subpackage	func.test
6
 * @copyright   Copyright 2004-2012, Fwolf
7
 * @author      Fwolf <[email protected]>
8
 * @since		2008-05-08
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
24
class TestFuncRequest extends UnitTestCase {
25
26
    function TestGetParam() {
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...
27
		$_GET = array('a' => 1);
28
		$x = GetParam();
0 ignored issues
show
Deprecated Code introduced by
The function GetParam() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlParam()

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...
29
		$y = '?a=1';
30
		$this->assertEqual($x, $y);
31
32
		$_GET = array('a' => 1);
33
		$x = GetParam('b', 2);
0 ignored issues
show
Deprecated Code introduced by
The function GetParam() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlParam()

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...
34
		$y = '?a=1&b=2';
35
		$this->assertEqual($x, $y);
36
37
		$_GET = array('a' => 1, 'b' => '', 'c' => 3);
38
		$x = GetParam(array('a' => 2, 1 => 'a'), array('b', 'c'));
0 ignored issues
show
Deprecated Code introduced by
The function GetParam() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlParam()

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...
39
		$y = '?a=2&1=a';
40
		$this->assertEqual($x, $y);
41
42
		$_GET = array('a' => 1, 'b' => '', 'c' => 3);
43
		$x = GetParam(array('a' => 2, 1 => 'a'), 'b');
0 ignored issues
show
Deprecated Code introduced by
The function GetParam() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlParam()

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...
44
		$y = '?a=2&c=3&1=a';
45
		$this->assertEqual($x, $y);
46
47
    } // end of func TestGetParam
48
49
50
    function TestGetUrlPlan() {
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...
51
    	$url = 'http://www.google.com/?a=https://something';
52
    	$this->assertEqual(GetUrlPlan($url), 'http');
0 ignored issues
show
Deprecated Code introduced by
The function GetUrlPlan() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlPlan()

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...
53
54
    	$url = 'https://www.fwolf.com/';
55
    	$this->assertEqual(GetUrlPlan($url), 'https');
0 ignored issues
show
Deprecated Code introduced by
The function GetUrlPlan() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlPlan()

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...
56
57
    	$url = 'ftp://domain.tld/';
58
    	$this->assertEqual(GetUrlPlan($url), 'ftp');
0 ignored issues
show
Deprecated Code introduced by
The function GetUrlPlan() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlPlan()

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...
59
60
    	$url = '';
61
    	$this->assertPattern('/https?/i', GetUrlPlan($url));
0 ignored issues
show
Deprecated Code introduced by
The function GetUrlPlan() has been deprecated with message: Use Fwlib\Util\HttpUtil::getUrlPlan()

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...
62
    } // end of func TestGetUrlPlan
63
64
} // end of class TestFuncRequest
65
66
67
// Change output charset in this way.
68
// {{{
69
$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...
70
$s_url = substr($s_url, strrpos($s_url, '/') + 1);
71
if ('request.test.php' == $s_url) {
72
	$test = new TestFuncRequest();
73
	$test->run(new HtmlReporter('utf-8'));
74
}
75
// }}}
76
?>
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...
77