From 1d7aef635ea470b0fc455482130b386f83dc4cfb Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Fri, 29 Sep 2017 13:14:39 +0200 Subject: [PATCH] dev #59187 attachments reading test --- library/Class/Entity.php | 5 + library/Class/WebService/Redmine/Issue.php | 17 +- .../View/Helper/Redmine/IssueJournal.php | 5 +- .../controllers/RedmineControllerTest.php | 2 +- tests/fixtures/RedmineFixtures.php | 278 +++++++++--------- 5 files changed, 149 insertions(+), 158 deletions(-) diff --git a/library/Class/Entity.php b/library/Class/Entity.php index d6ad0498a27..7b3e2df6eaf 100644 --- a/library/Class/Entity.php +++ b/library/Class/Entity.php @@ -46,6 +46,11 @@ class Class_Entity { } + public function __construct($attributes = []) { + $this->updateAttributes($attributes); + } + + public function get($name, $default=null) { return array_key_exists($name, $this->_attribs) ? $this->_attribs[$name] : $default; diff --git a/library/Class/WebService/Redmine/Issue.php b/library/Class/WebService/Redmine/Issue.php index a2a6819bc7d..a3a1c911f76 100644 --- a/library/Class/WebService/Redmine/Issue.php +++ b/library/Class/WebService/Redmine/Issue.php @@ -134,15 +134,18 @@ class Class_WebService_Redmine_Issue extends Class_Entity { } - public function renderAttachment($view, $key, $filename) { - if(!$filename) - return $view->tag('span', $this->_('Suppression de pièce jointe')); + public function renderAttachment($view, $attachment) { + if(!$attachment->getnew_value()) + return $view->tag('del', + $this->_('Pièce jointe : "%s"', $attachment->getold_value())); - $url = sprintf('%s/attachments/download/%s/%s', + $show_url = sprintf('%s/attachments/download/%s/%s', Class_AdminVar::get('REDMINE_SERVER_URL'), - $key, - $filename); - return $view->tagAnchor($url, $this->_('Pièce jointe : %s', $filename), ['target' => '_blank']); + $attachment->getname(), + $attachment->getnew_value()); + + return $view->tagAnchor($show_url, + $this->_('Pièce jointe : "%s"', $attachment->getnew_value()), ['target' => '_blank']); } diff --git a/library/ZendAfi/View/Helper/Redmine/IssueJournal.php b/library/ZendAfi/View/Helper/Redmine/IssueJournal.php index 239a72d690e..518e56cebcb 100644 --- a/library/ZendAfi/View/Helper/Redmine/IssueJournal.php +++ b/library/ZendAfi/View/Helper/Redmine/IssueJournal.php @@ -97,8 +97,7 @@ class ZendAfi_View_Helper_Redmine_IssueJournal extends ZendAfi_View_Helper_BaseH protected function renderDetail($detail) { if('attachment' == $detail['property']) return $this->_tag('li', $this->_issue->renderAttachment($this->view, - $detail['name'], - $detail['new_value'])); + new Class_Entity($detail))); if ('relation' == $detail['property']) return $this->_tag('li', $this->labelFromCode($detail['name'], isset($detail['old_value']) ? $detail['old_value'] : null, @@ -111,7 +110,7 @@ class ZendAfi_View_Helper_Redmine_IssueJournal extends ZendAfi_View_Helper_BaseH return $this->_tag('li', $this->getChangeLabel($this->customFrom($detail['name']), $detail['old_value'], $detail['new_value'])); - return ''; + return $this->_tag('li', implode(' ', $detail)); } diff --git a/tests/application/modules/admin/controllers/RedmineControllerTest.php b/tests/application/modules/admin/controllers/RedmineControllerTest.php index c52f2a7c348..3a818b1e1ce 100644 --- a/tests/application/modules/admin/controllers/RedmineControllerTest.php +++ b/tests/application/modules/admin/controllers/RedmineControllerTest.php @@ -500,7 +500,7 @@ class Admin_RedmineControllerEditIssue34247Test extends Admin_RedmineControllerF ['//ul//li', 'Priorité client changé de Normale à Urgente'], ['//td','test-support'], ['//td', '07/01/2016 à 09:30:26'], - + ['//td//a', 'Pièce jointe : "proof.jpg"'] ]; } diff --git a/tests/fixtures/RedmineFixtures.php b/tests/fixtures/RedmineFixtures.php index 47549333401..5bab9f300c1 100644 --- a/tests/fixtures/RedmineFixtures.php +++ b/tests/fixtures/RedmineFixtures.php @@ -58,33 +58,33 @@ class RedmineFixtures { public static function sandreIssues() { return ['issues' => [ ['id' => 34246, - 'project' => ['id' => 56, - 'name' => 'Développement Bokeh AFI-OPAC 2.0'], - 'tracker' => ['id' => 2, - 'name' => 'Développement'], - 'status' => ['id' => 7 , - 'name' => 'En développement'], - 'priority' => ['id' => 4, - 'name' => 'Normal'], - 'author' => ['id' => 207, - 'name' => 'gloas'], - 'assigned_to' => ['id' => 207, - 'name' => 'gloas'], - 'subject' => 'Charte graphique back-office', - 'description' => 'un ticket redmine', - 'done_ratio' => 30, - 'custom_fields' => [ ['id' => 37, - 'name' => 'Module Portail', - 'value' => ''], - ['id' => 5 , - 'name' => 'Priorité client', - 'value' => 'Normale'], - ['id' => 11, - 'name' => 'Phase', - 'value' => '']], - 'created_on' => '2015-12-04T09:19:11Z', - 'updated_on' => '2015-12-04T09:25:42Z', - 'story_points' => ''], + 'project' => ['id' => 56, + 'name' => 'Développement Bokeh AFI-OPAC 2.0'], + 'tracker' => ['id' => 2, + 'name' => 'Développement'], + 'status' => ['id' => 7 , + 'name' => 'En développement'], + 'priority' => ['id' => 4, + 'name' => 'Normal'], + 'author' => ['id' => 207, + 'name' => 'gloas'], + 'assigned_to' => ['id' => 207, + 'name' => 'gloas'], + 'subject' => 'Charte graphique back-office', + 'description' => 'un ticket redmine', + 'done_ratio' => 30, + 'custom_fields' => [ ['id' => 37, + 'name' => 'Module Portail', + 'value' => ''], + ['id' => 5 , + 'name' => 'Priorité client', + 'value' => 'Normale'], + ['id' => 11, + 'name' => 'Phase', + 'value' => '']], + 'created_on' => '2015-12-04T09:19:11Z', + 'updated_on' => '2015-12-04T09:25:42Z', + 'story_points' => ''], static::issue34247(), static::issue34248()], @@ -166,131 +166,115 @@ class RedmineFixtures { public static function issue34247WithJournals() { return [ 'issue' => - [ 'id' => 34247, - 'project' => [ 'id' => 214, - 'name' => 'Support Bokeh AFI-OPAC 2.0', - ], - 'tracker' => [ 'id' => 12, - 'name' => 'Demande d\'assistance', - ], - 'status' => [ 'id' => 2, - 'name' => 'Affecté au dév.', - ], - 'priority' => [ 'id' => 5, - 'name' => 'Haut', - ], - 'author' => [ 'id' => 207, - 'name' => 'gloas', - ], - 'assigned_to' => [ 'id' => 207, - 'name' => 'gloas', - ], - 'subject' => 'reindexation des champs personnalisés ', - 'description' => 'Url de l\'anomalie : http://web.afi-sa.net/miop-test.net/admin/custom-fields/edit/id/1 + [ 'id' => 34247, + 'project' => [ 'id' => 214, + 'name' => 'Support Bokeh AFI-OPAC 2.0', + ], + 'tracker' => [ 'id' => 12, + 'name' => 'Demande d\'assistance', + ], + 'status' => [ 'id' => 2, + 'name' => 'Affecté au dév.', + ], + 'priority' => [ 'id' => 5, + 'name' => 'Haut', + ], + 'author' => [ 'id' => 207, + 'name' => 'gloas', + ], + 'assigned_to' => [ 'id' => 207, + 'name' => 'gloas', + ], + 'subject' => 'reindexation des champs personnalisés ', + 'description' => 'Url de l\'anomalie : http://web.afi-sa.net/miop-test.net/admin/custom-fields/edit/id/1 Étapes pour parvenir au bug : * indexer un champs personnalisé * les facettes des notices des articles qui ont une valeur de paramétrée pour ce champ personnalisé ne sont pas mises à jour. ', - 'done_ratio' => 20, - 'spent_hours' => 0, - 'custom_fields' => [ [ 'id' => 43, - 'name' => 'Personne à contacter', - 'value' => 'Nom / prénom / email / téléphone', - ], - [ 'id' => 42, - 'name' => 'Pris en charge par', - 'value' => '', - ], - [ 'id' => 37, - 'name' => 'Module Portail', - 'value' => 'Recherche', - ], - [ 'id' => 5, - 'name' => 'Priorité client', - 'value' => 'Normale', - ], - [ 'id' => 1, - 'name' => 'Client', - 'value' => '', - ], - [ 'id' => 46, - 'name' => 'Relancé le', - 'value' => '', - ], - ], - 'created_on' => '2015-09-29T10:01:49Z', - 'updated_on' => '2015-12-02T13:37:49Z', - 'journals' => [ [ 'id' => 149465, - 'user' => [ 'id' => 1198, - 'name' => 'test-support', - ], - 'notes' => '', - 'created_on' => '2016-01-07T08:30:26Z', - 'details' => [ [ 'property' => 'relation', - 'name' => 'copied_from', - 'new_value' => '35800', - ], - ], - ], - [ 'id' => 149517, - 'user' => [ 'id' => 92, - 'name' => 'other', - ], - 'notes' => 'Pris en charge par le developpement', - 'created_on' => '2016-01-07T09:38:13Z', - 'details' => [ [ 'property' => 'attr', - 'name' => 'status_id', - 'old_value' => '1', - 'new_value' => '2', - ], - [ 'property' => 'attr', - 'name' => 'done_ratio', - 'old_value' => '0', - 'new_value' => '20', - ], - ], - ], - [ 'id' => 149608, - 'user' => [ 'id' => 92, - 'name' => 'dev', - ], - 'notes' => '', - 'created_on' => '2016-01-07T11:10:00Z', - 'details' => [ [ 'property' => 'relation', - 'name' => 'copied_to', - 'old_value' => '35831', - ], - ], - ], - [ 'id' => 149610, - 'user' => [ 'id' => 92, - 'name' => 'dev', - ], - 'notes' => '', - 'created_on' => '2016-01-07T11:10:04Z', - 'details' => [ [ 'property' => 'relation', - 'name' => 'blocks', - 'new_value' => '35831', - ], - ], - ], - [ 'id' => 149612, - 'user' => [ 'id' => 1198, - 'name' => 'test-support', - ], - 'notes' => '', - 'created_on' => '2016-01-07T11:12:45Z', - 'details' => [ [ 'property' => 'cf', - 'name' => '5', - 'old_value' => 'Normale', - 'new_value' => 'Urgente', - ], - ], - ], - ], - ], -]; + 'done_ratio' => 20, + 'spent_hours' => 0, + 'custom_fields' => [ [ 'id' => 43, + 'name' => 'Personne à contacter', + 'value' => 'Nom / prénom / email / téléphone', + ], + [ 'id' => 42, + 'name' => 'Pris en charge par', + 'value' => '', + ], + [ 'id' => 37, + 'name' => 'Module Portail', + 'value' => 'Recherche', + ], + [ 'id' => 5, + 'name' => 'Priorité client', + 'value' => 'Normale', + ], + [ 'id' => 1, + 'name' => 'Client', + 'value' => '', + ], + [ 'id' => 46, + 'name' => 'Relancé le', + 'value' => '', + ], + ], + 'created_on' => '2015-09-29T10:01:49Z', + 'updated_on' => '2015-12-02T13:37:49Z', + 'journals' => [['id' => 149465, + 'user' => [ 'id' => 1198, + 'name' => 'test-support'], + 'notes' => '', + 'created_on' => '2016-01-07T08:30:26Z', + 'details' => [['property' => 'relation', + 'name' => 'copied_from', + 'new_value' => '35800']]], + ['id' => 149517, + 'user' => ['id' => 92, + 'name' => 'other'], + 'notes' => 'Pris en charge par le developpement', + 'created_on' => '2016-01-07T09:38:13Z', + 'details' => [['property' => 'attr', + 'name' => 'status_id', + 'old_value' => '1', + 'new_value' => '2'], + ['property' => 'attr', + 'name' => 'done_ratio', + 'old_value' => '0', + 'new_value' => '20']]], + ['id' => 149608, + 'user' => ['id' => 92, + 'name' => 'dev'], + 'notes' => '', + 'created_on' => '2016-01-07T11:10:00Z', + 'details' => [['property' => 'relation', + 'name' => 'copied_to', + 'old_value' => '35831']]], + ['id' => 149610, + 'user' => ['id' => 92, + 'name' => 'dev'], + 'notes' => '', + 'created_on' => '2016-01-07T11:10:04Z', + 'details' => [['property' => 'relation', + 'name' => 'blocks', + 'new_value' => '35831']]], + ['id' => 149612, + 'user' => ['id' => 1198, + 'name' => 'test-support'], + 'notes' => '', + 'created_on' => '2016-01-07T11:12:45Z', + 'details' => [['property' => 'cf', + 'name' => '5', + 'old_value' => 'Normale', + 'new_value' => 'Urgente']]], + ['id' => 249465, + 'user' => ['id' => 1198, + 'name' => 'test-support'], + 'notes' => '', + 'created_on' => '2016-01-07T08:30:26Z', + 'details' => [['property' => 'attachment', + 'name' => '456789', + 'new_value' => 'proof.jpg']]]]]]; } -- GitLab