13 require_once(dirname(__FILE__) .
'/../common-parm.php');
21 protected function setUp() :
void
31 print
"Starting unit test for common-parm.php\n";
32 print
"test function GetParm()\n";
37 $result =
GetParm($Name, $Type);
38 $this->assertEquals(
"20", $result);
42 $result =
GetParm($Name, $Type);
43 $this->assertEquals(
"20.2", $result);
45 $_GET[$Name] =
"/test/";
47 $result =
GetParm($Name, $Type);
48 $this->assertEquals(
"/test/", $result);
50 $_GET[$Name] =
"\\test\\";
52 $result =
GetParm($Name, $Type);
53 $this->assertEquals(
"test", $result);
55 $_GET[$Name] =
"\\test\\";
57 $result =
GetParm($Name, $Type);
58 $this->assertEquals(
"\\test\\", $result);
60 $_POST[$Name] = $_GET[$Name];
63 $result =
GetParm($Name, $Type);
64 $this->assertEquals(
"test", $result);
67 $result =
GetParm($Name, $Type);
68 $this->assertEquals(
"", $result);
76 print
"test function Traceback()\n";
77 $expected =
"http://fossology.org/";
78 $_SERVER[
'REQUEST_URI'] = $expected;
80 $this->assertEquals($expected, $result);
88 print
"test function Traceback_uri()\n";
89 $source =
"http://fossology.org/?mod=test&parm=abc";
90 $expected =
"http://fossology.org/";
91 $_SERVER[
'REQUEST_URI'] = $source;
93 $this->assertEquals($expected, $result);
101 print
"test function Traceback_parm()\n";
102 $source1 =
"http://fossology.org/?mod=test";
103 $source2 =
"http://fossology.org/?mod=test&parm=abc";
104 $expected1 =
"test&parm=abc";
105 $expected2 =
"&parm=abc";
106 $_SERVER[
'REQUEST_URI'] = $source1;
108 $this->assertEquals(
"test", $result);
109 $_SERVER[
'REQUEST_URI'] = $source2;
111 $this->assertEquals($expected1, $result);
113 $this->assertEquals($expected2, $result);
121 print
"test function Traceback_parm_keep()\n";
122 $List = array(
'parm1',
'parm2');
123 $_GET[
'parm1'] =
"parm1";
124 $expected =
"&parm1=parm1";
126 $this->assertEquals($expected, $result);
134 print
"test function Traceback_dir()\n";
135 $source =
"http://fossology.org/repo/testdir?mod=test&parm=abc";
136 $_SERVER[
'REQUEST_URI'] = $source;
137 $expected =
"http://fossology.org/repo/";
139 $this->assertEquals($expected, $result);
140 print
"Ending unit test for common-parm.php\n";
test_Traceback_parm()
test for Traceback_parm()
test_Traceback()
test for Traceback()
test_Traceback_parm_keep()
test for Traceback_parm_keep()
test_Traceback_uri()
test for Traceback_uri()
test_Traceback_dir()
test for Traceback_dir()
test_GetParm()
test for GetParm($Name, $Type)
Traceback_uri()
Get the URI without query to this location.
Traceback_parm($ShowMod=1)
Get the URI query to this location.
Traceback_dir()
Get the directory of the URI without query.
Traceback()
Get the URI + query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.