Commit f2afb02c authored by Laurent's avatar Laurent
Browse files

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

hotline #98102 reset thumbnail for album records force re-downloading of thumbnail from third party thumbnail provider
parent 5d74dfe5
Pipeline #9060 passed with stage
in 64 minutes and 40 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();
......
Markdown is supported
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