diff --git a/application/modules/admin/controllers/CatalogueController.php b/application/modules/admin/controllers/CatalogueController.php index 536fcb5aba3a2ee6db85ebc4f5806a7b2e87ae22..89d366e7e4bfdff9c93b085d6a73488ab64526dd 100644 --- a/application/modules/admin/controllers/CatalogueController.php +++ b/application/modules/admin/controllers/CatalogueController.php @@ -201,11 +201,7 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { return $this->_redirect("admin/catalogue/index"); if ($id_panier_to_remove = (int)$this->_getParam('remove')) { - $panier = Class_PanierNotice::find($id_panier_to_remove); - $catalogue->removePanierNotice($panier)->save(); - $panier->removeCatalogue($catalogue)->save(); - - $this->_helper->notify($this->_('Panier "%s" retiré', $panier->getLibelle())); + $this->_removePanierFromCatalogue($id_panier_to_remove,$catalogue); return $this->_redirect('admin/catalogue/paniers/id_catalogue/' . $catalogue->getId()); } @@ -229,6 +225,16 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { } + protected function _removePanierFromCatalogue($panier_id,$catalogue){ + $panier = Class_PanierNotice::find($panier_id); + if (!$panier) + return; + + $catalogue->removePanierNotice($panier)->save(); + $panier->removeCatalogue($catalogue)->save(); + $this->_helper->notify($this->_('Panier "%s" retiré', $panier->getLibelle())); + } + protected function formAjoutPanier($catalogue) { $options = ['' => $this->_('Veuiller sélectionner un panier')]; $paniers = Class_PanierNotice::findAllBelongsToAdmin(); diff --git a/library/Class/Cosmogramme/Integration/PhasePanier.php b/library/Class/Cosmogramme/Integration/PhasePanier.php index 2f2a35b95d3dfb190a69cc978cc190491cc815a7..b74d9c841caf2f2400db9b084c24e184924cddc1 100644 --- a/library/Class/Cosmogramme/Integration/PhasePanier.php +++ b/library/Class/Cosmogramme/Integration/PhasePanier.php @@ -175,5 +175,6 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr protected function _afterFileProcessed($integration) { + $cart_todelete = Class_PanierNotice::deleteBy(['notices'=>"", 'id_int_bib'=>$integration->getIdBib()]); } } diff --git a/library/templates/Intonation/Library/Widget/Carousel/Record/View.php b/library/templates/Intonation/Library/Widget/Carousel/Record/View.php index 87dd001bdc3c668d38c4d09da69364f1a72e684f..5045a6aa6a7d27331c94589837775d6c2bb5b9cd 100644 --- a/library/templates/Intonation/Library/Widget/Carousel/Record/View.php +++ b/library/templates/Intonation/Library/Widget/Carousel/Record/View.php @@ -105,4 +105,4 @@ class Intonation_Library_Widget_Carousel_Record_View extends Intonation_Library_ protected function _getWrapper() { return 'Intonation_Library_View_Wrapper_Record'; } -} \ No newline at end of file +} diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php index e62f284ae2f4d99b4cd206caa37edb02c61d41eb..2bca243f8ca794b907a7344c45dc6e46234480a9 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php @@ -186,15 +186,8 @@ class PhasePanierKohaSameIdOrigineTest extends PhasePanierKohaTestCase { /** @test */ - public function fourthBasketRecordsShouldBeEmpty() { - $this->assertEmpty(Class_PanierNotice::find(4)->getClesNotices()); - } - - - /** @test */ - public function fourthBasketIntegrationHashShouldBe577f79a2c26968b6f5e1360df0dc17af() { - $this->assertEquals('577f79a2c26968b6f5e1360df0dc17af', - Class_PanierNotice::find(4)->getIntegrationHash()); + public function fourthBasketRecordsShouldBeDeleted() { + $this->assertEmpty(Class_PanierNotice::find(4)); } @@ -234,8 +227,8 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase { /** @test */ - public function numberOfBasketsShouldBeTen() { - $this->assertCount(10, Class_PanierNotice::findAll()); + public function numberOfBasketsShouldBeEight() { + $this->assertCount(8, Class_PanierNotice::findAll()); } @@ -281,11 +274,6 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase { } - /** @test */ - public function basketTitiShouldBeEmpty() { - $this->assertEmpty(Class_PanierNotice::findFirstBy(['id_sigb' => 7])->getClesNotices()); - } - /** @test */ public function litteratureShouldHave1Item() { @@ -325,6 +313,13 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase { public function missingIDAbonWithEmailShouldBeOk(){ $this->assertEquals('tintin', Class_PanierNotice::findFirstBy(['libelle' => 'bd,texte'])->getUser()->getLogin()); } + + + /* cf. https://forge.afi-sa.net/issues/97326 */ + /** @test */ + public function emptyCart7RelatedToIntBib2ShouldBeDeleted(){ + $this->assertEquals(null,Class_PanierNotice::find(7)); + } } @@ -342,6 +337,8 @@ class PhasePanierFullImportWithCSVSemicolonTest extends PhasePanierFullImportTes 'format' => Class_IntProfilDonnees::FORMAT_SEMI_COLON_ASCII, 'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]); + Class_PanierNotice::find(4)->setIntegrationHash('998745bb68ef9ab13b4de262b444e5d1')->save(); + Class_Cosmogramme_Integration::find(999) ->setFichier('baskets-semicolon.txt') ->setProfilDonnees(Class_IntProfilDonnees::find(103)) @@ -363,6 +360,7 @@ class PhasePanierFullImportWithCSVPipedTest extends PhasePanierFullImportTest { 'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII, 'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]); + Class_PanierNotice::find(4)->setIntegrationHash('279f738e761e127ec19ca08cec9386ce')->save(); Class_Cosmogramme_Integration::find(999) ->setFichier('baskets-piped.txt') ->setProfilDonnees(Class_IntProfilDonnees::find(104)) @@ -456,6 +454,7 @@ class PhasePanierNanookTest extends PhasePanierTestCase { $this->fixture('Class_Notice', ['id' => 23, + 'type_doc' => Class_TypeDoc::LIVRE, 'clef_alpha' => 'CASTAFIORE', 'exemplaires' => [$this->fixture('Class_Exemplaire', ['id' => 231,