13 use PHPUnit\Runner\Version as PHPUnitVersion;
15 require_once(dirname(__FILE__) .
'/../common-menu.php');
16 require_once(dirname(__FILE__) .
'/../common-parm.php');
24 protected function setUp() :
void
33 print
"Starting unit test for common-menu.php\n";
34 print
"test function MenuPage()\n";
38 $Uri =
"http://fossology.org/repo/";
39 $expected =
"<a class='page-link' href='http:\/\/fossology.org\/repo\/&page=9'>Prev<\/a>";
40 $result =
MenuPage($Page, $TotalPage, $Uri);
41 if (intval(explode(
'.', PHPUnitVersion::id())[0]) >= 9) {
42 $this->assertMatchesRegularExpression(
"/<a class='page-link' href='#'>11<\/a>/", $result);
43 $this->assertMatchesRegularExpression(
"/$expected/", $result);
45 $this->assertRegExp(
"/<a class='page-link' href='#'>11<\/a>/", $result);
46 $this->assertRegExp(
"/$expected/", $result);
55 print
"test function MenuEndlessPage()\n";
58 $Uri =
"http://fossology.org/repo/";
59 $expected =
"<a class='page-link' href='http:\/\/fossology.org\/repo\/&page=9'>Prev<\/a>";
61 if (intval(explode(
'.', PHPUnitVersion::id())[0]) >= 9) {
62 $this->assertMatchesRegularExpression(
"/<a class='page-link' href='#'>11<\/a>/", $result);
63 $this->assertMatchesRegularExpression(
"/$expected/", $result);
65 $this->assertRegExp(
"/<a class='page-link' href='#'>11<\/a>/", $result);
66 $this->assertRegExp(
"/$expected/", $result);
75 print
"test function menu_cmp()\n";
79 $menua->Name =
'menua';
80 $menub->Name =
'menua';
82 $this->assertEquals(0,$result);
86 $this->assertEquals(1,$result);
93 print
"test function menu_insert()\n";
97 $Path =
"TestMenu::Test1::Test2";
100 $Title =
"TestTitle";
101 $Target =
"TestTarget";
104 $result =
menu_insert($Path, $LastOrder, $URI, $Title, $Target, $HTML);
105 $this->assertEquals($Path,
106 $MenuList[$countMenuListBefore]->SubMenu[0]->SubMenu[0]->FullName);
108 print
"test function menu_find)\n";
112 print
"test function menu_to_1html)\n";
114 $pattern =
"/TestMenu/";
115 if (intval(explode(
'.', PHPUnitVersion::id())[0]) >= 9) {
116 $this->assertMatchesRegularExpression($pattern, $result);
118 $this->assertRegExp($pattern, $result);
121 print
"test function menu_to_1list)\n";
124 if (intval(explode(
'.', PHPUnitVersion::id())[0]) >= 9) {
125 $this->assertMatchesRegularExpression($pattern, $result);
127 $this->assertRegExp($pattern, $result);
129 print
"Ending unit test for common-menu.php\n";