Skip to content
Snippets Groups Projects
Commit 4d1b82a2 authored by Laurent's avatar Laurent
Browse files

dev #19571 basket import

manage integrations from several SIGB
parent 7df8166d
Branches
Tags
4 merge requests!896Master,!893Master,!887Dev#19571 paniers,!865Dev#19571 paniers
......@@ -27,4 +27,11 @@ try {
$adapter->query('alter table notices_paniers add column id_sigb int(11), add key id_sigb (id_sigb)');
}
try {
$adapter->query('select id_int_bib from notices_paniers limit 1');
} catch (Exception $e) {
$adapter->query('alter table notices_paniers add column id_int_bib int(11), add key id_int_bib (id_int_bib)');
}
?>
\ No newline at end of file
......@@ -52,7 +52,7 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
}
protected function mapRecordColumns($datas) {
protected function mapRecordColumns($integration, $datas) {
$attribs = unserialize($integration->getProfilDonnees()->getAttributs());
$fields = explode(';', $attribs[3]['champs']);
$map = [];
......@@ -63,7 +63,7 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
protected function importBasketRecord($datas, $integration) {
$map = $this->mapRecordColumns($datas);
$map = $this->mapRecordColumns($integration, $datas);
$possible_owners = $this->findPossibleOwnersOfBasketRecord($map);
if ($possible_owners->isEmpty())
......@@ -90,7 +90,7 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
protected function _clean($integration) {
$baskets = Class_PanierNotice::findAllBy(['id_sigb not' => null]);
$baskets = Class_PanierNotice::findAllBy(['id_int_bib' => $integration->getId()]);
foreach($baskets as $basket)
$basket->setNotices('')->save();
}
......
......@@ -104,6 +104,7 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
$this->fixture('Class_PanierNotice',
['id' => 1,
'id_sigb' => 1,
'id_int_bib' => 123,
'libelle' => 'ciné',
'notices' => 'COKEENSTOCK']);
......@@ -114,6 +115,14 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
'libelle' => 'mon panier',
'notices' => 'AFFAIRETOURNESOL']);
$this->fixture('Class_PanierNotice',
['id' => 3,
'id_user' => 4,
'id_sigb' => 1,
'id_int_bib' => 98,
'libelle' => 'mon autre panier',
'notices' => 'VOL714']);
$this->fixture('Class_Notice',
['id' => 23,
......@@ -166,8 +175,8 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
/** @test */
public function numberOfBasketsShouldBeThree() {
$this->assertCount(3, Class_PanierNotice::findAll());
public function numberOfBasketsShouldBeFour() {
$this->assertCount(4, Class_PanierNotice::findAll());
}
......@@ -178,8 +187,8 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
/** @test */
public function thirdBasketLibelleShouldBeFroidLitterature() {
$this->assertEquals('froid litterature', Class_PanierNotice::find(3)->getLibelle());
public function fourthBasketLibelleShouldBeFroidLitterature() {
$this->assertEquals('froid litterature', Class_PanierNotice::find(4)->getLibelle());
}
......@@ -202,8 +211,14 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
/** @test */
public function thirdBasketShouldBeOwnedByTintin() {
$this->assertEquals('tintin', Class_PanierNotice::find(3)->getUser()->getLogin());
public function thirdBasketShouldNotBeModified() {
$this->assertEquals(['VOL714'], Class_PanierNotice::find(3)->getClesNotices());
}
/** @test */
public function fourthBasketShouldBeOwnedByTintin() {
$this->assertEquals('tintin', Class_PanierNotice::find(4)->getUser()->getLogin());
}
/** @test */
......@@ -214,9 +229,9 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
/** @test */
public function thirdBasketRecordsShouldContainsTIBET() {
public function fourthBasketRecordsShouldContainsTIBET() {
$this->assertEquals(['TIBET'],
Class_PanierNotice::find(3)->getClesNotices());
Class_PanierNotice::find(4)->getClesNotices());
}
......
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