From 6e720ab4623234485ca810532cc984473c471685 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Fri, 17 Mar 2017 11:17:30 +0100 Subject: [PATCH] hotline #57170 update record thumbnail on cache server should pass collection key for serial --- VERSIONS_HOTLINE/57170 | 1 + .../Notice/Thumbnail/ProviderCacheServer.php | 9 ++--- tests/library/Class/NoticeTest.php | 40 ++++++++++++++++++- 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 VERSIONS_HOTLINE/57170 diff --git a/VERSIONS_HOTLINE/57170 b/VERSIONS_HOTLINE/57170 new file mode 100644 index 00000000000..016b102edda --- /dev/null +++ b/VERSIONS_HOTLINE/57170 @@ -0,0 +1 @@ + - ticket #57170 : Correction de l'intégration d'une vignette pour une notice de périodique \ No newline at end of file diff --git a/library/Class/Notice/Thumbnail/ProviderCacheServer.php b/library/Class/Notice/Thumbnail/ProviderCacheServer.php index 6aa4a7556d5..027801d93ba 100644 --- a/library/Class/Notice/Thumbnail/ProviderCacheServer.php +++ b/library/Class/Notice/Thumbnail/ProviderCacheServer.php @@ -38,18 +38,15 @@ class Class_Notice_Thumbnail_ProviderCacheServer protected function _getUrls() { $record = $this->_record; - $titre = $record->isPeriodique() - ? $record->getClefChapeau() - : $record->getTitrePrincipal(); - $numero = $record->isPeriodique() ? $record->getTomeAlpha() : ''; - $args = ["titre" => $titre, + $args = ["titre" => $record->getTitrePrincipal(), "auteur"=> $record->getAuteurPrincipal(), "isbn" => $record->getIsbn(), "ean" => $record->getEan(), "type_doc" => $record->getFamilleId(), - "numero" => $numero]; + "numero" => $numero, + "clef_chapeau" => $record->getClefChapeau()]; $response = Class_WebService_AllServices::runServiceGetUrlVignette($args); diff --git a/tests/library/Class/NoticeTest.php b/tests/library/Class/NoticeTest.php index 80fc096d567..5bf14699a97 100644 --- a/tests/library/Class/NoticeTest.php +++ b/tests/library/Class/NoticeTest.php @@ -56,7 +56,7 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase { ->touch('notice_2.png'); Class_WebService_Vignette::setFileSystem($this->_filesystem); - + Class_CosmoVar::setValueOf('url_services', 'http://cache.org'); $this->_notice_without_thumbnails = $this->fixture('Class_Notice', ['id' => 1, @@ -64,7 +64,6 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase { 'url_vignette' => '', 'url_image' => '']); - $this->_notice_inexisting_thumbnails = $this->fixture('Class_Notice', ['id' => 2, 'type_doc' => Class_TypeDoc::LIVRE, @@ -120,6 +119,17 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase { 'id_notice' => 5, 'titre' => 'LinuxFR', 'url' => 'http://www.linuxfr.org']); + + + $this->_serial_without_thumbnails = $this->fixture('Class_Notice', + ['id' => 9, + 'type_doc' => Class_TypeDoc::PERIODIQUE, + 'tome_alpha' => '123', + 'titre_principal' => 'Monde Diplo: mars 2017', + 'clef_chapeau' => 'Monde Diplo', + 'auteur_principal' => 'diplo', + 'url_vignette' => '', + 'url_image' => '']); } @@ -131,6 +141,7 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase { parent::tearDown(); } + /** @test */ public function withoutThumbnailFetchUrlVignetteShouldAnswerVignetteActionForAjax() { $this->assertContains('/recherche/vignette/clef/', @@ -148,6 +159,31 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase { } + + /** @test */ + public function serialWithThumbnailFetchUrlLocalVignetteShouldPassMainTitleAndCollectionKey() { + $this->_http_client + ->whenCalled('open_url') + ->with('http://cache.org?' + .'titre='.urlencode('Monde Diplo: mars 2017') + .'&auteur=diplo' + .'&type_doc=2' + .'&numero=123' + .'&clef_chapeau='.urlencode('Monde Diplo') + .'&src='.Class_WebService_AllServices::createSecurityKey() + .'&api=2.0' + .'&action=10') + ->answers(json_encode(['statut_recherche' => '0', + 'source' => 'Amazon', + 'vignette' => 'diplo.jpg', + 'image' => 'diplo.jpg'])) + ->beStrict(); + + $this->assertEquals('/temp/vignettes_titre/notice_9.png', + $this->_serial_without_thumbnails->fetchUrlLocalVignette()); + } + + /** @test */ public function withInexistingThumbnailFetchUrlVignetteShouldAnswerLocalUrl() { $this->assertFalse($this->_http_client->methodHasBeenCalled('open_url')); -- GitLab