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

Merge branch...

Merge branch 'hotline#98102_ebooks_notices_vignettes_pnb_en_resultat_de_rrecherche_manquante' into 'hotline'

hotline #98102 reset thumbnail for album records force re-downloading of…

See merge request !3358
parents 385e793d f2afb02c
Branches
Tags
2 merge requests!3365Hotline,!3358hotline #98102 reset thumbnail for album records force re-downloading of…
Pipeline #9126 passed with stage
in 46 minutes and 17 seconds
- ticket #98102 : Notices d'album : le bouton "générer" pour la vignette force le retéléchargement de cette vignette pour les ressources numériques externes
\ No newline at end of file
......@@ -27,25 +27,34 @@ class Admin_RecordsController extends ZendAfi_Controller_Action {
return $this->_redirectToReferer();
}
if ($album = $record->getAlbum()){
$album->createThumbnail();
$url_vignette = $album->getThumbnailUrl();
$this->_resetRecordThumbnail($record);
$record->setUrlVignette($url_vignette);
$record->setUrlImage(($poster = $album->getPoster()) ? $poster : $url_vignette);
$record->save();
$this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal()));
$this->_redirectToReferer();
}
$this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal()));
return $this->_redirectToReferer();
protected function _resetRecordThumbnail($record) {
if (!$album = $record->getAlbum()) {
$record
->setUrlImage('')
->setUrlVignette('')
->fetchUrlLocalVignette();
return $this;
}
$record
->setUrlImage('')
->setUrlVignette('')
->fetchUrlLocalVignette();
Class_WebService_BibNumerique_Vignette::getInstance()->updateAlbum($album);
foreach($album->getErrors() as $error)
$this->_helper->notify($error);
$this->_helper->notify($this->_('Vignette réinitialisée pour "%s"', $record->getTitrePrincipal()));
$this->_redirectToReferer();
$album->createThumbnail();
$url_vignette = $album->getThumbnailUrl();
$record->setUrlVignette($url_vignette);
$record->setUrlImage(($poster = $album->getPoster()) ? $poster : $url_vignette);
$record->save();
return $this;
}
......
......@@ -107,6 +107,7 @@ class RecordsControllerResetThumbnailTest extends RecordsControllerTestCase {
class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase {
public function setUp() {
parent::setUp();
......@@ -126,6 +127,14 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
$album->index();
$id = $album->getNoticeId();
Class_WebService_BibNumerique_Vignette::setInstance(
$this->mock()
->whenCalled('updateAlbum')
->willDo(function($album)
{
$album->addError('Error downloading thumbnail');
}));
$this->dispatch('/admin/records/reset-thumbnail/id/' . $id, true);
Class_Notice::clearCache();
......@@ -133,6 +142,20 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
}
/** @test */
public function albumVignetteShouldHaveBeenUpdated() {
$this->assertTrue(Class_WebService_BibNumerique_Vignette::getInstance()
->methodHasBeenCalledWithParams('updateAlbum',
[Class_Album::find(5)]));
}
/** @test */
public function responseShouldNotifyErrorDownloadingThumbnail() {
$this->assertFlashMessengerContentContains('Error downloading thumbnail');
}
/** @test */
public function urlImageShouldPotter() {
$this->assertContains('/userfiles/album/5/thumb_potter.png', $this->_notice->getUrlImage());
......@@ -159,6 +182,7 @@ class RecordsControllerResetAlbumThumbnailTest extends RecordsControllerTestCase
class RecordsControllerResetThumbnailUnknowRecordTest extends RecordsControllerTestCase {
public function setUp() {
parent::setUp();
......@@ -180,6 +204,7 @@ class RecordsControllerResetThumbnailUnknowRecordTest extends RecordsControllerT
class RecordsControllerThumbnailTest extends RecordsControllerTestCase {
public function setUp() {
parent::setUp();
......
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