From 14fa7398496ed6696dfff0606da0e2c283f513c3 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT <hdlaurent@afi-sa.fr> Date: Mon, 27 Jan 2020 12:32:38 +0100 Subject: [PATCH] hotline #103756 : cart integration was broken when no cart was linked to Domains --- VERSIONS_HOTLINE/103756 | 1 + .../Cosmogramme/Integration/PhasePanier.php | 11 +++++--- .../Integration/PhasePanierTest.php | 28 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 VERSIONS_HOTLINE/103756 diff --git a/VERSIONS_HOTLINE/103756 b/VERSIONS_HOTLINE/103756 new file mode 100644 index 00000000000..ea0d5efd0c9 --- /dev/null +++ b/VERSIONS_HOTLINE/103756 @@ -0,0 +1 @@ + - ticket #103756 : Intégrations : Correction d'une erreur pouvant survenir lors de l'import des paniers \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhasePanier.php b/library/Class/Cosmogramme/Integration/PhasePanier.php index 79ced34fbc0..7aaf7cf74cf 100644 --- a/library/Class/Cosmogramme/Integration/PhasePanier.php +++ b/library/Class/Cosmogramme/Integration/PhasePanier.php @@ -177,9 +177,12 @@ class Class_Cosmogramme_Integration_PhasePanier protected function _afterFileProcessed($integration) { - Class_PanierNotice::deleteBy(['notices' => '', - 'id_int_bib' => $integration->getIdBib(), - 'id not' => Class_PanierNotice::findAllIdsWithCatalogue() - ]); + $params = ['notices' => '', + 'id_int_bib' => $integration->getIdBib()]; + + if ($linked_to_domain = Class_PanierNotice::findAllIdsWithCatalogue()) + $params['id not'] = $linked_to_domain; + + Class_PanierNotice::deleteBy($params); } } diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php index 049de9b90d7..9ce502309cd 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php @@ -228,6 +228,34 @@ class PhasePanierKohaSameIdOrigineTest extends PhasePanierKohaTestCase { +class PhasePanierFullImportWithoutLinkedToDomainTest extends PhasePanierKohaTestCase { + protected $_wrapper; + + public function _prepareFixtures() { + parent::_prepareFixtures(); + Class_PanierNotice::find(5)->delete(); + + $this->onLoaderOfModel('Class_PanierNotice'); + Class_Cosmogramme_Integration::find(999)->beTotalImport()->save(); + } + + + /** @test */ + public function noLinkedToDomainShouldExists() { + $this->assertEquals([], Class_PanierNotice::findAllIdsWithCatalogue()); + } + + + /** @test */ + public function panierDeleteByShouldNotContainsIdParam() { + $this->assertNotContains('id not', + array_keys(Class_PanierNotice::getFirstAttributeForLastCallOn('deleteBy'))); + } +} + + + + class PhasePanierFullImportTest extends PhasePanierKohaTestCase { public function _prepareFixtures() { parent::_prepareFixtures(); -- GitLab