diff --git a/VERSIONS_HOTLINE/101519 b/VERSIONS_HOTLINE/101519 new file mode 100644 index 0000000000000000000000000000000000000000..d519b3fc1ef106dd2626dae7bbcc830ce73b08ae --- /dev/null +++ b/VERSIONS_HOTLINE/101519 @@ -0,0 +1 @@ + - ticket #101519 : Intégration : Bokeh ne supprime pas automatiquement les paniers devenus vides lorsqu'ils sont reliés à un domaine \ No newline at end of file diff --git a/library/Class/Cosmogramme/Integration/PhasePanier.php b/library/Class/Cosmogramme/Integration/PhasePanier.php index b74d9c841caf2f2400db9b084c24e184924cddc1..79ced34fbc04229d5c6f429edd958ea7e6a524ca 100644 --- a/library/Class/Cosmogramme/Integration/PhasePanier.php +++ b/library/Class/Cosmogramme/Integration/PhasePanier.php @@ -20,7 +20,9 @@ */ -class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integration_PhaseOnDataSource { +class Class_Cosmogramme_Integration_PhasePanier + extends Class_Cosmogramme_Integration_PhaseOnDataSource { + const MY_ID = 15; protected $_label = 'Intégration des fichiers paniers'; @@ -175,6 +177,9 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr protected function _afterFileProcessed($integration) { - $cart_todelete = Class_PanierNotice::deleteBy(['notices'=>"", 'id_int_bib'=>$integration->getIdBib()]); + Class_PanierNotice::deleteBy(['notices' => '', + 'id_int_bib' => $integration->getIdBib(), + 'id not' => Class_PanierNotice::findAllIdsWithCatalogue() + ]); } } diff --git a/library/Class/PanierNotice.php b/library/Class/PanierNotice.php index f2c143247ceebff4a446f6faa7c74cec91d93c36..38cf26b1dc5bca1fcb0e1bffefb29d5e546a63b7 100644 --- a/library/Class/PanierNotice.php +++ b/library/Class/PanierNotice.php @@ -58,8 +58,13 @@ class PanierNoticeLoader extends Storm_Model_Loader { public function findAllIdsWithCatalogue() { - $panier_notice_catalogue = Class_PanierNoticeCatalogue::getLoader()->findAll(); - $ids_with_catalogue = array_map(function($association) {return $association->getIdPanier();}, $panier_notice_catalogue); + $panier_notice_catalogue = Class_PanierNoticeCatalogue::findAll(); + $ids_with_catalogue = array_map(function($association) + { + return $association->getIdPanier(); + }, + $panier_notice_catalogue); + return array_filter(array_unique($ids_with_catalogue)); } @@ -114,6 +119,7 @@ class PanierNoticeLoader extends Storm_Model_Loader { + class Class_PanierNotice extends Storm_Model_Abstract { use Trait_Translator, Trait_Indexable, Trait_TimeSource; diff --git a/library/Class/PanierNoticeCatalogue.php b/library/Class/PanierNoticeCatalogue.php index 798ee61800e8473b22e746c9439eb33862b17347..dca6cfafd4e4a9860cd8d683dafb3ee7bd64b81c 100644 --- a/library/Class/PanierNoticeCatalogue.php +++ b/library/Class/PanierNoticeCatalogue.php @@ -16,11 +16,11 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Class_PanierNoticeCatalogue extends Storm_Model_Abstract { - protected + protected $_table_name = 'notices_paniers_catalogues', $_belongs_to = ['catalogue' => ['model' => 'Class_Catalogue', 'referenced_in' => 'id_catalogue'], @@ -28,5 +28,3 @@ class Class_PanierNoticeCatalogue extends Storm_Model_Abstract { 'panier_notice' => ['model' => 'Class_PanierNotice', 'referenced_in' => 'id_panier']]; } - -?> \ 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 2bca243f8ca794b907a7344c45dc6e46234480a9..049de9b90d7030c9c69572d47d96da79fa692a1d 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePanierTest.php @@ -126,6 +126,21 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase { 'libelle' => 'will be killed', 'notices' => 'VOL714']); + $this->fixture('Class_PanierNotice', + ['id' => 5, + 'id_user' => 3, + 'id_sigb' => 1, + 'id_int_bib' => 2, + 'integration_hash' => '577f79a2c26968b6f5e1360df0dc17af', + 'libelle' => 'will not be killed due to domain link', + 'notices' => 'VOL714']); + + $this->fixture('Class_Catalogue', + ['id' => 42, + 'libelle' => 'Catalogue']); + + Class_PanierNotice::find(5)->setDomaineIds(42); + $this->fixture('Class_Notice', ['id' => 23, 'type_doc' => 1, @@ -162,7 +177,6 @@ abstract class PhasePanierKohaTestCase extends PhasePanierTestCase { 'id_int_bib' => 2, 'id_origine' => 58265])]]); } - } @@ -181,13 +195,19 @@ class PhasePanierKohaSameIdOrigineTest extends PhasePanierKohaTestCase { Class_Exemplaire::deleteBy([]); Class_IntProfilDonnees::deleteBy([]); Class_Cosmogramme_Integration::deleteBy([]); - parent:: tearDown(); + parent::tearDown(); + } + + + /** @test */ + public function emptyBasketWithoutLinkedDomainShouldBeDeleted() { + $this->assertNull(Class_PanierNotice::find(4)); } /** @test */ - public function fourthBasketRecordsShouldBeDeleted() { - $this->assertEmpty(Class_PanierNotice::find(4)); + public function emptyBasketWithLinkedDomainShouldNotBeDeleted() { + $this->assertNotNull(Class_PanierNotice::find(5)); } @@ -200,7 +220,8 @@ class PhasePanierKohaSameIdOrigineTest extends PhasePanierKohaTestCase { /** @test */ public function firstBasketRecordsShouldContainsCOKEENSTOCKCASTAFIORELUNE() { - $this->assertEquals('COKEENSTOCK;CASTAFIORE;LUNE', Class_PanierNotice::find(1)->getNotices()); + $this->assertEquals('COKEENSTOCK;CASTAFIORE;LUNE', + Class_PanierNotice::find(1)->getNotices()); } } @@ -228,7 +249,7 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase { /** @test */ public function numberOfBasketsShouldBeEight() { - $this->assertCount(8, Class_PanierNotice::findAll()); + $this->assertCount(9, Class_PanierNotice::findAll()); } @@ -293,7 +314,7 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase { /** @test */ public function basketFiveRecordsShouldContainsTIBET() { $this->assertEquals(['TIBET'], - Class_PanierNotice::find(5)->getClesNotices()); + Class_PanierNotice::find(7)->getClesNotices()); } @@ -318,7 +339,14 @@ class PhasePanierFullImportTest extends PhasePanierKohaTestCase { /* cf. https://forge.afi-sa.net/issues/97326 */ /** @test */ public function emptyCart7RelatedToIntBib2ShouldBeDeleted(){ - $this->assertEquals(null,Class_PanierNotice::find(7)); + $this->assertEquals(null,Class_PanierNotice::find(8)); + } + + + /* cf. https://forge.afi-sa.net/issues/101519 */ + /** @test */ + public function emptyCartWithLinkedDomainShouldBePresent(){ + $this->assertNotNull(Class_PanierNotice::find(5)); } } @@ -415,8 +443,8 @@ class PhasePanierFullImportWithWrongProfilTest extends PhasePanierKohaTestCase { /** @test */ - public function numberOfBasketsShouldBeFour() { - $this->assertCount(4, Class_PanierNotice::findAll()); + public function numberOfBasketsShouldBeFive() { + $this->assertCount(5, Class_PanierNotice::findAll()); } }