From 12b47b4c718ca80095dac0005f9908d47defe889 Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Thu, 30 Jan 2020 11:17:00 +0100 Subject: [PATCH] refactor(targetticket): remove workaround Signed-off-by: Thierry Bugier --- inc/common.class.php | 29 ----------- inc/targetticket.class.php | 25 +++++---- tests/suite-unit/PluginFormcreatorCommon.php | 54 -------------------- 3 files changed, 12 insertions(+), 96 deletions(-) diff --git a/inc/common.class.php b/inc/common.class.php index ddf9b7f55..044a57f56 100644 --- a/inc/common.class.php +++ b/inc/common.class.php @@ -82,35 +82,6 @@ public static function getGlpiVersion() { : GLPI_VERSION; } - /** - * Get Link Name - * - * @param integer $value Current value - * @param boolean $inverted Whether to invert label - * - * @return string - */ - public static function getLinkName($value, $inverted = false) { - $tmp = []; - - if (!$inverted) { - $tmp[Ticket_Ticket::LINK_TO] = __('Linked to'); - $tmp[Ticket_Ticket::DUPLICATE_WITH] = __('Duplicates'); - $tmp[Ticket_Ticket::SON_OF] = __('Son of'); - $tmp[Ticket_Ticket::PARENT_OF] = __('Parent of'); - } else { - $tmp[Ticket_Ticket::LINK_TO] = __('Linked to'); - $tmp[Ticket_Ticket::DUPLICATE_WITH] = __('Duplicated by'); - $tmp[Ticket_Ticket::SON_OF] = __('Parent of'); - $tmp[Ticket_Ticket::PARENT_OF] = __('Son of'); - } - - if (isset($tmp[$value])) { - return $tmp[$value]; - } - return NOT_AVAILABLE; - } - /** * Gets the ID of Formcreator request type */ diff --git a/inc/targetticket.class.php b/inc/targetticket.class.php index b399a5977..2c7123fe9 100644 --- a/inc/targetticket.class.php +++ b/inc/targetticket.class.php @@ -321,18 +321,19 @@ protected function showCompositeTicketSettings($rand) { // show already linked items foreach ($rows as $row) { - $icons = ' '.Html::getSimpleForm(PluginFormcreatorItem_TargetTicket::getFormURL(), 'purge', - _x('button', 'Delete permanently'), - ['id' => $row['id']], - 'fa-times-circle'); - $itemtype = $row['itemtype']; - $item = new $itemtype(); - $item->getFromDB($row['items_id']); + $icons = ' '.Html::getSimpleForm( + PluginFormcreatorItem_TargetTicket::getFormURL(), + 'purge', + _x('button', 'Delete permanently'), + ['id' => $row['id']], + 'fa-times-circle' + ); + $itemtype = $row['itemtype']; + $item = new $itemtype(); + $item->getFromDB($row['items_id']); switch ($itemtype) { case Ticket::getType(): - //TODO: when merge of https://github.com/glpi-project/glpi/pull/2840 (this is a BC) - //echo Ticket_Ticket::getLinkName($row['link']); - echo PluginFormcreatorCommon::getLinkName($row['link']); + echo Ticket_Ticket::getLinkName($row['link']); echo ' '; echo $itemtype::getTypeName(); echo ' '; @@ -342,9 +343,7 @@ protected function showCompositeTicketSettings($rand) { break; case PluginFormcreatorTargetTicket::getType(): - // TODO: when merge of https://github.com/glpi-project/glpi/pull/2840 (this is a BC) - //echo Ticket_Ticket::getLinkName($row['link']); - echo PluginFormcreatorCommon::getLinkName($row['link']); + echo Ticket_Ticket::getLinkName($row['link']); echo ' '; echo $itemtype::getTypeName(); echo ' '; diff --git a/tests/suite-unit/PluginFormcreatorCommon.php b/tests/suite-unit/PluginFormcreatorCommon.php index f249c39d7..a87ff8ce4 100644 --- a/tests/suite-unit/PluginFormcreatorCommon.php +++ b/tests/suite-unit/PluginFormcreatorCommon.php @@ -62,60 +62,6 @@ public function testSetNotification() { $this->integer((int) $CFG_GLPI['use_notifications'])->isEqualTo('1'); } - public function providerGetLinkName() { - return [ - [ - 'value' => '1', - 'inverted' => false, - 'expected' => 'Linked to', - ], - [ - 'value' => '2', - 'inverted' => false, - 'expected' => 'Duplicates', - ], - [ - 'value' => '3', - 'inverted' => false, - 'expected' => 'Son of', - ], - [ - 'value' => '4', - 'inverted' => false, - 'expected' => 'Parent of', - ], - [ - 'value' => '1', - 'inverted' => true, - 'expected' => 'Linked to', - ], - [ - 'value' => '2', - 'inverted' => true, - 'expected' => 'Duplicated by', - ], - [ - 'value' => '3', - 'inverted' => true, - 'expected' => 'Parent of', - ], - [ - 'value' => '4', - 'inverted' => true, - 'expected' => 'Son of', - ], - ]; - } - - /** - * @dataProvider providerGetLinkName - */ - public function testGetLinkName($value, $inverted, $expected) { - $output = \PluginFormcreatorCommon::getLinkName($value, $inverted); - $this->string($output)->isEqualTo($expected); - } - - public function providerGetPictoFilename() { return [ [