From 9172688da345e0f8d21716963aaa7ac9e3112bf5 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Wed, 15 Jun 2022 14:44:59 +0200 Subject: [PATCH] fix Error 500 for interviews following move of files --- library/Class/WebService/Afi.php | 13 +++++++++- .../Intonation/View/RenderInterviews.php | 2 +- tests/scenarios/Templates/TemplatesTest.php | 25 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/library/Class/WebService/Afi.php b/library/Class/WebService/Afi.php index 1d45eb57596..44f7fcb824a 100644 --- a/library/Class/WebService/Afi.php +++ b/library/Class/WebService/Afi.php @@ -46,7 +46,9 @@ class Class_WebService_Afi extends Class_WebService_Abstract { TRAILER_ENABLED = 0, TRAILER_DISABLED = 1; - protected static $_key; + protected static + $_key, + $_should_throw_error; /** @category testing */ public static function setKey($key) { @@ -61,6 +63,11 @@ class Class_WebService_Afi extends Class_WebService_Abstract { } + public static function shouldThrowError($should) { + static::$_should_throw_error = $should; + } + + public function getBiography($args) { return array_merge(['statut_recherche' => 1, 'erreur' => '', @@ -252,6 +259,10 @@ class Class_WebService_Afi extends Class_WebService_Abstract { $url = $url_service . '?' . http_build_query($args); + if (static::$_should_throw_error) + return $response = $this->httpGet($url, $options); + + try { $response = $this->httpGet($url, $options); static::_goGoGadgetoLog(); diff --git a/library/templates/Intonation/View/RenderInterviews.php b/library/templates/Intonation/View/RenderInterviews.php index 19b996dc244..03089f57cdb 100644 --- a/library/templates/Intonation/View/RenderInterviews.php +++ b/library/templates/Intonation/View/RenderInterviews.php @@ -43,6 +43,6 @@ class Intonation_View_RenderInterviews extends ZendAfi_View_Helper_BaseHelper { $interview->getDescription()))); }; - return $this->view->renderCarousel($interviews, $callback); + return $this->view->layoutCarousel($interviews, $callback); } } diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php index 42724bebfad..eec4473a9c5 100644 --- a/tests/scenarios/Templates/TemplatesTest.php +++ b/tests/scenarios/Templates/TemplatesTest.php @@ -1476,6 +1476,31 @@ class TemplatesDispatchRecordAuthorTest extends TemplatesIntonationTestCase { 'type_doc' => 8, 'clef_oeuvre' => 'THE BOOK OF SOULS', 'facettes' => 'G13 M12 A2408']); + + $httpClient = + $this->mock() + ->whenCalled('open_url') + ->with('https://www.youtube.com/feeds/videos.xml?channel_id=123') + ->answers('') + ->whenCalled('open_url') + ->with('https://cache.org?auteur=Iron+Maiden&width=500&src=99aed22943ef35851f70f99965a44690&api=2.0&action=7') + ->answers(['source' => 'http://ina.fr', + 'videos' => [['titre' =>'abcdef', + 'player' => 'src="http://mycontent.org/interview"', + 'contenu'=>'Mycontent']] + ]) + ->beStrict(); + + Class_CosmoVar::setValueOf('url_services', 'https://cache.org'); + Class_WebService_Afi::shouldThrowError(true); + Class_WebService_Afi::setHttpClient($httpClient); + } + + public function tearDown() { + Class_WebService_Afi::shouldThrowError(false); + Class_WebService_Afi::setHttpClient(null); + + parent::tearDown(); } -- GitLab