Skip to content
Snippets Groups Projects
Commit 9e010cd2 authored by Henri-Damien LAURENT's avatar Henri-Damien LAURENT Committed by Patrick Barroca
Browse files

hotline#101519 : do not delete empty Basket with linked domain

parent d90da5ce
Branches
Tags
3 merge requests!3342Master,!3336Hotline,!3330hotline#101519 : Cosmogramme : Basket deletions occurs only when not linked with…
Pipeline #8934 failed with stage
in 37 minutes and 30 seconds
- 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
......@@ -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()
]);
}
}
......@@ -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;
......
......@@ -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
......@@ -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());
}
}
......
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