Skip to content
Snippets Groups Projects
Commit 300c4955 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#57170_impossibilite_d_integrer_une_vignette_pour_un_periodique' into 'stable'

hotline #57170 update record thumbnail on cache server should pass collection key for serial

See merge request !2081
parents 22a72a14 c53a8449
Branches
Tags
5 merge requests!2334Master,!2088Master,!2085Master,!2084Hotline master,!2081hotline #57170 update record thumbnail on cache server should pass collection key for serial
Pipeline #882 passed with stage
in 21 minutes and 36 seconds
- ticket #57170 : Correction de l'intégration d'une vignette pour une notice de périodique
\ No newline at end of file
......@@ -38,19 +38,18 @@ 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];
if ($record->isPeriodique())
$args["clef_chapeau"] = $record->getClefChapeau();
$response = Class_WebService_AllServices::runServiceGetUrlVignette($args);
if ($response["statut_recherche"] != 2)
......
......@@ -34,7 +34,9 @@ class NoticeFixtures extends TestFixtures {
class NoticeVignetteTest extends Storm_Test_ModelTestCase {
class NoticeVignetteTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
......@@ -56,7 +58,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 +66,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,
......@@ -111,8 +112,11 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase {
$preferences= [ 'thumbnail_fields' => '700-a;856-u'];
Class_Profil::getCurrentProfil()
->setCfgModules(['recherche' => ['viewnotice'.Class_TypeDoc::DISQUE => $preferences]]);
$this->fixture('Class_Profil',
['id' => 1,
'libelle' => 'portail',
'cfg_modules' => ['recherche' => ['viewnotice'.Class_TypeDoc::DISQUE => $preferences]]])
->beCurrentProfil();
$this->fixture('Class_Sitotheque',
......@@ -120,6 +124,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 +146,7 @@ class NoticeVignetteTest extends Storm_Test_ModelTestCase {
parent::tearDown();
}
/** @test */
public function withoutThumbnailFetchUrlVignetteShouldAnswerVignetteActionForAjax() {
$this->assertContains('/recherche/vignette/clef/',
......@@ -148,6 +164,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'));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment