Skip to content
Snippets Groups Projects
Commit 2f0780ef authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

version 7.3.37

Merge remote-tracking branch 'refs/remotes/afi/stable' into afi-hotline-master

# Conflicts:
#	VERSIONS
#	library/startup.php
parents 65778f1c c762aaa3
Branches
Tags 7.3.37
8 merge requests!1553Master,!1502Master,!1501Stable,!1363Master,!1362Master,!1360Master,!1344Master,!1343Hotline master
14/12/2015 - v7.3.37
- ticket #33149 : Correction SSO CAS LeKiosk
- ticket #33712 : Nanook : Les paniers exportés sont rattachés à l'administrateur Bokeh
10/12/2015 - v7.3.36
- ticket #32959 : Avenio : Réimport de notices d'archives
......
- ticket #33149 : Correction SSO CAS LeKiosk
\ No newline at end of file
......@@ -31,16 +31,19 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
$errors = [];
$fields = $this->getFields($profil);
if (false === array_search('ID_SIGB',$fields))
$errors []= 'Configuration: colonne ID_SIGB requise';
if (false === array_search('ID_SIGB', $fields))
$errors[] = 'Configuration: colonne ID_SIGB requise';
if (false === array_search('ID_ABON',$fields) && false === array_search('MAIL', $fields))
$errors []= 'Configuration: colonne IDABON ou MAIL requise';
if (false === array_search('ID_ABON', $fields)
&& false === array_search('MAIL', $fields))
$errors[] = 'Configuration: colonne IDABON ou MAIL requise';
array_map([$this->_log, 'addError'], $errors);
array_map( [$this->_log, 'addError'], $errors);
return empty($errors);
}
protected function _processLine($line, $integration) {
$line->withDataDo(
function($data) use ($integration){
......@@ -49,57 +52,59 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
}
protected function findPossibleOwnersOfBasketRecord($map) {
$possible_owners = new Storm_Model_Collection();
$users = new Storm_Model_Collection();
if ($map['mail'])
$possible_owners->addAll(Class_Users::findAllBy(['mail' => $map['mail']]));
$users->addAll(Class_Users::findAllBy(['mail' => $map['mail']]));
if ($map['idabon'])
$possible_owners->addAll(Class_Users::findAllBy(['idabon' => $map['idabon']]));
$users->addAll(Class_Users::findAllBy(['idabon' => $map['idabon']]));
$possible_owners = $possible_owners->select((1 == (int)$map['role'])
? 'isBibliothecaire'
: 'isAbonne');
return $possible_owners;
$users = $users->select((1 == (int)$map['role'])
? 'isBibliothecaire'
: 'isAbonne');
return $users;
}
protected function mapRecordColumns($integration, $datas) {
$fields=$this->getFields($integration->getProfilDonnees());
$fields = $this->getFields($integration->getProfilDonnees());
$map = [];
foreach($fields as $k => $name) {
foreach($fields as $k => $name)
$map[strtolower($name)] = $datas[$k];
}
return $map;
}
protected function getFields($profil_donnees) {
$attribs = unserialize($profil_donnees->getAttributs());
return explode(';', $attribs[3]['champs']);
}
protected function importBasketRecord($datas, $integration) {
if (sizeof($datas) != sizeof($this->getFields($integration->getProfilDonnees())))
return;
$map = $this->mapRecordColumns($integration, $datas);
$possible_owners = $this->findPossibleOwnersOfBasketRecord($map);
if ($possible_owners->isEmpty())
return $this->_log->addError('Panier orphelin: '.$map['libelle']);
protected function importBasketRecord($datas, $integration) {
if (sizeof($datas) != sizeof($this->getFields($integration->getProfilDonnees())))
return;
$map = $this->mapRecordColumns($integration, $datas);
if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $map['id_notice_sigb']]))
return;
$owner = $possible_owners->first();
$owners = $this->findPossibleOwnersOfBasketRecord($map);
if ($owners->isEmpty() && $integration->isPergame())
$owners->addAll([Class_Users::find(1)]);
if ($owners->isEmpty())
return $this->_log->addError('Panier orphelin: ' . $map['libelle']);
$owner = $owners->first();
$id_sigb = $map['id_sigb'];
$basket = Class_PanierNotice::findFirstBy(['id_sigb' => $id_sigb]);
if ($id_sigb==null || !$basket) {
if ($id_sigb == null || !$basket)
$basket = Class_PanierNotice::newInstance()->initializeForUser($owner);
}
$basket
->setLibelle($map['libelle'])
......@@ -119,13 +124,17 @@ class Class_Cosmogramme_Integration_PhasePanier extends Class_Cosmogramme_Integr
protected function _shouldIgnoreLine($line, $integration) {
return false;
return $line->withDataDo([$this, 'isHeader']);
}
public function isHeader($data) {
return false !== array_search('ID_SIGB', $data);
}
protected function _afterFileProcessed($integration) {
Class_PanierNotice::deleteBy(['id_int_bib' => $integration->getId(),
'notices' => '']);
}
}
?>
\ No newline at end of file
......@@ -64,7 +64,7 @@ function defineConstant($name, $value) {
function setupConstants() {
defineConstant('BOKEH_MAJOR_VERSION','7.3');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.36');
defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.37');
defineConstant('BOKEH_REMOTE_FILES', 'http://git.afi-sa.fr/afi/opacce/');
......
......@@ -20,27 +20,23 @@
*/
abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTestCase {
protected $_log, $_phase, $_printer;
public function setUp() {
parent::setUp();
$this->_phase = $this->_buildPhase('Panier')
->setPrinter($this->_printer)
->run();
protected function _getPreviousPhase() {
return (new Class_Cosmogramme_Integration_Phase(14))
->beCron();
}
public function _prepareFixtures() {
$this->fixture('Class_CosmoVar', ['id' => 'import_format', 'liste' => '']);
Class_CosmoVar::addLabelInList('import_format',
Class_IntProfilDonnees::FORMAT_CSV,
'CSV');
$this->fixture('Class_IntBib',
['id' => 2,
'nom_court' => 'Annexe 2',
'sigb' => 1]);
['id' => 2,
'nom_court' => 'Annexe 2',
'sigb' => 12]);
$this->fixture('Class_IntProfilDonnees',
['id' => 102,
......@@ -58,9 +54,24 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
'traite' => 'non',
'fichier' => 'baskets.txt',
'pointeur_reprise' => 0]);
}
public function setUp() {
parent::setUp();
$this->_phase = $this->_buildPhase('Panier')
->setPrinter($this->_printer)
->run();
}
}
abstract class PhasePanierKohaTestCase extends PhasePanierTestCase {
public function _prepareFixtures() {
parent::_prepareFixtures();
$this->fixture('Class_Users',
['id' => 1,
'login' => 'milou_pro',
......@@ -78,7 +89,6 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
'idabon' => '0006',
'mail' => 'milou@herge.fr']);
$this->fixture('Class_Users',
['id' => 3,
'login' => 'tintin',
......@@ -117,7 +127,6 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
'libelle' => 'will be killed',
'notices' => 'VOL714']);
$this->fixture('Class_Notice',
['id' => 23,
'clef_alpha' => 'CASTAFIORE',
......@@ -139,26 +148,23 @@ abstract class PhasePanierTestCase extends Class_Cosmogramme_Integration_PhaseTe
['id' => 4511,
'id_origine' => 72490])]]);
}
protected function _getPreviousPhase() {
return (new Class_Cosmogramme_Integration_Phase(14))
->beCron();
}
}
class PhasePanierFullImportTest extends PhasePanierTestCase {
class PhasePanierFullImportTest extends PhasePanierKohaTestCase {
public function _prepareFixtures() {
parent::_prepareFixtures();
Class_Cosmogramme_Integration::find(999)->beTotalImport()->save();
}
/** @test */
public function newPhaseShouldBe17() {
$this->assertTrue($this->_phase->isId(15));
}
/** @test */
public function logShouldContainsPhaseLabel() {
$this->assertLogContains('Intégration des fichiers paniers');
......@@ -218,6 +224,7 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
$this->assertNull(Class_PanierNotice::find(4));
}
/** @test */
public function litteratureShouldHave1Item() {
$this->assertEquals(1, sizeof(Class_PanierNotice::findFirstBy(['libelle' => 'froid litterature'])->getClesNotices()));
......@@ -243,11 +250,13 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
$this->assertLogContains('Panier orphelin: trou noir');
}
/** @test */
public function logShouldContainsPanierOrphelinVideSideral() {
$this->assertLogContains('Panier orphelin: vide sideral');
}
/** @test */
public function missingIDAbonWithEmailShouldBeOk(){
$this->assertEquals('tintin', Class_PanierNotice::findFirstBy(['libelle' => 'bd,texte'])->getUser()->getLogin());
......@@ -260,6 +269,7 @@ class PhasePanierFullImportTest extends PhasePanierTestCase {
class PhasePanierFullImportWithCSVSemicolonTest extends PhasePanierFullImportTest {
public function _prepareFixtures() {
parent::_prepareFixtures();
$this->fixture('Class_IntProfilDonnees',
['id' => 103,
'libelle' => 'Koha Baskets',
......@@ -268,10 +278,10 @@ class PhasePanierFullImportWithCSVSemicolonTest extends PhasePanierFullImportTes
'format' => Class_IntProfilDonnees::FORMAT_SEMI_COLON_ASCII,
'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]);
$integration=Class_Cosmogramme_Integration::find(999);
$integration->setFichier('baskets-semicolon.txt')->setProfilDonnees(Class_IntProfilDonnees::find(103));
$integration->save();
Class_Cosmogramme_Integration::find(999)
->setFichier('baskets-semicolon.txt')
->setProfilDonnees(Class_IntProfilDonnees::find(103))
->save();
}
}
......@@ -289,20 +299,16 @@ class PhasePanierFullImportWithCSVPipedTest extends PhasePanierFullImportTest {
'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII,
'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]);
$integration=Class_Cosmogramme_Integration::find(999);
$integration->setFichier('baskets-piped.txt')->setProfilDonnees(Class_IntProfilDonnees::find(104));
$integration->save();
Class_Cosmogramme_Integration::find(999)
->setFichier('baskets-piped.txt')
->setProfilDonnees(Class_IntProfilDonnees::find(104))
->save();
}
}
class PhasePanierPartialImportTest extends PhasePanierTestCase {
class PhasePanierPartialImportTest extends PhasePanierKohaTestCase {
public function _prepareFixtures() {
parent::_prepareFixtures();
......@@ -316,6 +322,7 @@ class PhasePanierPartialImportTest extends PhasePanierTestCase {
Class_PanierNotice::find(1)->getClesNotices());
}
/** @test */
public function fourthBasketShouldNotBeDeleted() {
$this->assertNotNull(Class_PanierNotice::find(4));
......@@ -324,7 +331,7 @@ class PhasePanierPartialImportTest extends PhasePanierTestCase {
class PhasePanierFullImportWithWrongProfilTest extends PhasePanierTestCase {
class PhasePanierFullImportWithWrongProfilTest extends PhasePanierKohaTestCase {
public function _prepareFixtures() {
parent::_prepareFixtures();
Class_IntProfilDonnees::find(102)
......@@ -338,16 +345,75 @@ class PhasePanierFullImportWithWrongProfilTest extends PhasePanierTestCase {
$this->assertLogContains('Configuration: colonne ID_SIGB requise');
}
/** @test */
public function logShouldContainsErrorIDABON_OR_MAIL_ColumnRequired() {
$this->assertLogContains('Configuration: colonne IDABON ou MAIL requise');
}
/** @test */
public function numberOfBasketsShouldBeFour() {
$this->assertCount(4, Class_PanierNotice::findAll());
}
}
?>
\ No newline at end of file
/** @see http://forge.afi-sa.fr/issues/33712 */
class PhasePanierNanookTest extends PhasePanierTestCase {
protected $_basket;
public function _prepareFixtures() {
parent::_prepareFixtures();
Class_IntBib::find(2)->setSigb(13);
$this->fixture('Class_IntProfilDonnees',
['id' => 104,
'libelle' => 'Paniers Nanook',
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'type_fichier' => Class_IntProfilDonnees::FT_BASKETS,
'format' => Class_IntProfilDonnees::FORMAT_PIPED_ASCII,
'attributs' => [3 => ['champs' => 'ID_SIGB;LIBELLE;IDABON;MAIL;ROLE;ID_NOTICE_SIGB']]]);
Class_Cosmogramme_Integration::find(999)
->setFichier('paniers-nanook.txt')
->setProfilDonnees(Class_IntProfilDonnees::find(104))
->save();
$this->fixture('Class_Users',
['id' => 1,
'login' => 'admin',
'password' => 'secret',
'role_level' => ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN,
'idabon' => '',
'mail' => '']);
$this->fixture('Class_Notice',
['id' => 23,
'clef_alpha' => 'CASTAFIORE',
'exemplaires' => [$this->fixture('Class_Exemplaire',
['id' => 231,
'id_origine' => 45633])]]);
}
public function setUp() {
parent::setUp();
$this->_basket = Class_PanierNotice::findFirstBy([]);
}
/** @test */
public function shouldImportBasket() {
$this->assertNotNull($this->_basket);
}
/** @test */
public function shouldLinkBasketToAdmin() {
$this->assertEquals(1, $this->_basket->getIdUser());
}
}
ID_SIGB|LIBELLE|IDABON|MAIL|ROLE|NOTICE_SIGB
509|SC - Coupe du monde rugby 15|||1|45633
509|SC - Coupe du monde rugby 15|||1|189699
509|SC - Coupe du monde rugby 15|||1|35169
509|SC - Coupe du monde rugby 15|||1|3397
509|SC - Coupe du monde rugby 15|||1|70909
509|SC - Coupe du monde rugby 15|||1|143403
509|SC - Coupe du monde rugby 15|||1|70176
509|SC - Coupe du monde rugby 15|||1|29279
509|SC - Coupe du monde rugby 15|||1|169637
509|SC - Coupe du monde rugby 15|||1|168247
509|SC - Coupe du monde rugby 15|||1|70811
509|SC - Coupe du monde rugby 15|||1|143599
509|SC - Coupe du monde rugby 15|||1|176152
509|SC - Coupe du monde rugby 15|||1|189705
509|SC - Coupe du monde rugby 15|||1|132714
509|SC - Coupe du monde rugby 15|||1|29259
509|SC - Coupe du monde rugby 15|||1|132920
509|SC - Coupe du monde rugby 15|||1|70915
509|SC - Coupe du monde rugby 15|||1|29320
509|SC - Coupe du monde rugby 15|||1|62347
509|SC - Coupe du monde rugby 15|||1|51523
509|SC - Coupe du monde rugby 15|||1|61199
509|SC - Coupe du monde rugby 15|||1|45113
509|SC - Coupe du monde rugby 15|||1|130923
509|SC - Coupe du monde rugby 15|||1|64007
509|SC - Coupe du monde rugby 15|||1|63995
509|SC - Coupe du monde rugby 15|||1|74117
509|SC - Coupe du monde rugby 15|||1|154795
509|SC - Coupe du monde rugby 15|||1|29276
509|SC - Coupe du monde rugby 15|||1|62627
509|SC - Coupe du monde rugby 15|||1|63987
509|SC - Coupe du monde rugby 15|||1|70806
509|SC - Coupe du monde rugby 15|||1|29275
509|SC - Coupe du monde rugby 15|||1|132954
509|SC - Coupe du monde rugby 15|||1|64009
509|SC - Coupe du monde rugby 15|||1|26298
509|SC - Coupe du monde rugby 15|||1|169638
509|SC - Coupe du monde rugby 15|||1|63984
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