Commit 0b2a7a9c authored by Patrick Barroca's avatar Patrick Barroca 🐧 Committed by Laurent

hotline #109494 : fix error in pnb dilicom export when album has been deleted

parent 95d1bd15
Pipeline #10521 canceled with stage
in 38 minutes and 57 seconds
- ticket #109494 : PNB Dilicom : Correction d'une erreur lors de l'export des prèts quand l'album dilicom a été supprimé
\ No newline at end of file
......@@ -152,7 +152,10 @@ class Class_Loan_Pnb extends Storm_Model_Abstract {
public function getItem() {
foreach(Class_Album_Item::findAllBy(['album_id' => $this->getAlbum()->getId()])
if (!$album = $this->getAlbum())
return;
foreach(Class_Album_Item::findAllBy(['album_id' => $album->getId()])
as $item)
if ($item->getOrderLineId() == $this->getOrderLineId())
return $item;
......
......@@ -25,7 +25,7 @@
*/
trait Trait_AlbumDelegator {
public function getNoticeOPACId() {
return $this->getAlbum()->getNoticeId();
return $this->_withAlbumGet('notice_id');
}
......@@ -40,42 +40,44 @@ trait Trait_AlbumDelegator {
public function getTitle() {
return $this->getAlbum()->getTitre();
return $this->_withAlbumGet('titre', '');
}
public function getMainAuthor() {
return $this->getAlbum()->getMainAuthorName();
return $this->_withAlbumGet('main_author_name', '');
}
public function getFirstEditor() {
return $this->getAlbum()->getFirstEditor();
return $this->_withAlbumGet('first_editor', '');
}
public function getFirstCollection() {
return $this->getAlbum()->getFirstCollection();
return $this->_withAlbumGet('first_collection', '');
}
public function getYear() {
return $this->getAlbum()->getAnnee();
return $this->_withAlbumGet('annee', '');
}
public function getFirstKind() {
return $this->getFirstLabelFromAlbumCodif('Class_CodifGenre', $this->getAlbum()->getGenre());
return $this->getFirstLabelFromAlbumCodif('Class_CodifGenre',
$this->_withAlbumGet('genre', ''));
}
public function getFirstSection() {
return $this->getFirstLabelFromAlbumCodif('Class_CodifSection', $this->getAlbum()->getSections());
return $this->getFirstLabelFromAlbumCodif('Class_CodifSection',
$this->_withAlbumGet('sections'));
}
public function getCategory() {
return $this->getAlbum()->getCategoryLabel();
return $this->_withAlbumGet('category_label', '');
}
......@@ -85,4 +87,11 @@ trait Trait_AlbumDelegator {
? ''
: $labels->first();
}
protected function _withAlbumGet($attribute, $default=null) {
return ($album = $this->getAlbum())
? $album->callGetterByAttributeName($attribute)
: $default;
}
}
......@@ -3862,7 +3862,7 @@ class PnbDilicomAdminAlbumControllerExportLoansCsvTest extends PnbDilicomAdminAl
'loan_link' => 'https://pnb-dilicom.centprod.com/v2//XXXXXXXX.do',
'order_line_id' => '82377a045ce56ef0a072a8b']);
$this->dispatch('admin/album/dilicom-export-loans-csv', true);
$this->dispatch('admin/album/dilicom-export-loans-csv');
}
......@@ -3898,6 +3898,29 @@ class PnbDilicomAdminAlbumControllerExportLoansCsvTest extends PnbDilicomAdminAl
class PnbDilicomAdminAlbumControllerExportLoansCsvWithMissingAlbumTest
extends PnbDilicomAdminAlbumControllerTestCase {
public function setUp() {
parent::setUp();
Class_Album::find(23)->delete();
$this->dispatch('admin/album/dilicom-export-loans-csv');
}
/** @test */
public function filenameShouldBeDilicomLoansCsv() {
$this->assertContains(['name' => 'Content-Type',
'value' => 'text/csv; name="dilicom_loans_csv.csv"',
'replace' => true],
$this->_response->getHeaders());
}
}
class PnbDilicomAdminIndexControllerTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
......
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