diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index f98b71b64af0d86fddb921be3d19d94a43d25165..df13fb706321aad2f37f57db380bf266a4a6c3b7 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -400,7 +400,7 @@ class AbonneController extends ZendAfi_Controller_Action { $id_pret = $this->_getParam('id_pret'); $ids = array_filter(explode(';', $id_pret)); if (!count($ids)) { - $this->_renderExtendPopup([$this->_('Aucune prolongation éffectué.')]); + $this->_renderExtendPopup([$this->_('Aucune prolongation éffectuée.')]); return; } @@ -1021,22 +1021,24 @@ class AbonneController extends ZendAfi_Controller_Action { public function barcodesExportAction() { - $this->_helper->viewRenderer->setNoRender(); - - $datas = []; - $emprunts = $this->_user->getLoansWithoutPNB($this->_request->getParams()); - foreach($emprunts as $emprunt) { - if (!$exemplaire = $emprunt->getExemplaireOPAC()) - continue; - - $datas[] = (string) $exemplaire->getCodeBarres(); - } - $filename = $this->_('prets_codes_barres_%s_%s%s', $this->_user->getId(), uniqid(), - '.json'); - $this->_helper->binaryDownload(json_encode(array_filter($datas)), $filename); + '.csv'); + + $description = (new Class_TableDescription('loans-barcodes')) + ->addColumn('', function($loan) + { + return $loan->getCodeBarre(); + }); + + $datas = array_filter($this->_user + ->getLoansWithoutPNB($this->_request->getParams()) + ->getArrayCopy()); + + $this->_helper->csv($filename, + $this->view->renderCsv($description, + $datas)); } diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index 608e997f3f893fc07c0932d6cd6e83cc5edb9026..15408aa841b04bb9ea5e180a03874555e0761cde 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -1104,16 +1104,10 @@ class AbonneControllerPretsListMoreThanUndredHoldsTest extends AbonneControllerP class AbonneControllerBarcodesExportThreePretsTest extends AbonneControllerPretsListThreePretsTestCase { - protected - $_dl_file, - $_json = ['124', '123']; public function setUp() { parent::setUp(); $this->dispatch('abonne/barcodes-export', true); - $this->_dl_file = tempnam('/tmp', 'JSON'); - file_put_contents($this->_dl_file, $this->_response->getBody()); - $this->_json = json_encode($this->_json); } @@ -1131,14 +1125,9 @@ class AbonneControllerBarcodesExportThreePretsTest extends AbonneControllerPrets /** @test */ - public function bodyShouldContainsJsons() { - $this->assertSame($this->_json, $this->_response->getBody()); - } - - - /** @test */ - public function dlFileShouldContainsJson() { - $this->assertEquals($this->_json, file_get_contents($this->_dl_file)); + public function bodyShouldContainsBarCodes() { + $this->assertContains('124', $this->_response->getBody()); + $this->assertContains('123', $this->_response->getBody()); } } diff --git a/tests/scenarios/HandleOnholdTest/HandleOnholdTest.php b/tests/scenarios/HandleOnholdTest/HandleOnholdTest.php index 0b3710c91c93a19fc943ecb3f6ab90f60abba132..2ad7ef06751d3509deaab431d0eaac623ee98cab 100644 --- a/tests/scenarios/HandleOnholdTest/HandleOnholdTest.php +++ b/tests/scenarios/HandleOnholdTest/HandleOnholdTest.php @@ -206,7 +206,7 @@ abstract class HandleOnholdDispatchTestCase extends HandleOnholdTestCase { /** @test */ - public function exportJsonShouldBeDisplay() { + public function exportBarcodesShouldBeDisplay() { $this->dispatch('/opac/abonne/prets/onhold/yes', true); $this->assertXPathContentContains('//a[contains(@href, "abonne/barcodes-export/onhold/yes")]', 'Export codes barres'); }