Skip to content

Commit 775ac3d

Browse files
committed
N°3815 - Remove "DisplayTemplate" PHP classes - TemplateMenuNode::GetHyperlink() must return ''
1 parent 83927af commit 775ac3d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

application/menunode.class.inc.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,13 @@ public function __construct($sMenuId, $sTemplateFile, $iParentIndex, $fRank = 0.
903903
{
904904
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
905905
}
906-
906+
/**
907+
* @inheritDoc
908+
*/
909+
public function GetHyperlink($aExtraParams)
910+
{
911+
return '';
912+
}
907913
/**
908914
* @inheritDoc
909915
* @throws \Exception

tests/php-unit-tests/unitary-tests/application/UI/Base/Layout/NavigationMenuTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace UI\Base\Layout;
44

55
use ApplicationContext;
6+
use ApplicationMenu;
67
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
78
use Combodo\iTop\Application\UI\Base\Layout\NavigationMenu\NavigationMenu;
89
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
@@ -61,4 +62,20 @@ public function testIsAllowed_BackwardCompatibility_NoVariableInConfFile(){
6162
$this->assertEquals(true, $isAllowed);
6263
unlink($sTmpFilePath);
6364
}
65+
66+
/**
67+
* test GetHyperlink return empty for TemplateMenuNode and ShortcutContainerMenuNode only
68+
*/
69+
public function testGetHyperlink(){
70+
ApplicationMenu::LoadAdditionalMenus();
71+
foreach (ApplicationMenu::$aMenusIndex as $sMenuId => $aMenu) {
72+
//echo ' **** '. get_class($aMenu['node']);
73+
if(in_array(get_class($aMenu['node']), ['TemplateMenuNode','ShortcutContainerMenuNode']) ){
74+
$this->assertEquals('', $aMenu['node']->GetHyperlink([]), 'Menu node '.$sMenuId.' is a TemplateMenuNode. It should have empty hyperlink');
75+
} else {
76+
$this->assertNotEquals('', $aMenu['node']->GetHyperlink([]),'Menu node '.$sMenuId.' is a '.get_class($aMenu['node']).'. It should have not empty hyperlink');
77+
}
78+
}
79+
}
80+
6481
}

0 commit comments

Comments
 (0)