Commit d8844739 authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch 'hotline#106988_import_periodiques_pmb' into 'hotline'

hotline #106988 Fix PMB serial import with items in zone 996

See merge request !3430
parents 7d8cd4b9 1eb10950
Pipeline #9711 failed with stage
in 43 minutes and 56 seconds
- ticket #106988 : Intégrations : correction de la détection du type de document basé sur un sous-champ de la zone exemplaire autre que 995
\ No newline at end of file
......@@ -1134,13 +1134,19 @@ class notice_unimarc extends iso2709_record {
$label = $this->inner_guide['dt'] . $this->inner_guide['bl'];
$champ_code_barres = $this->getBarcode();
if (!isset($this->profil['attributs'][0]['item_zone']) || !$zone = $this->profil['attributs'][0]['item_zone'])
$zone = '995';
if ($this->profil['attributs'][0]['champ_type_doc']) {
$zone = (strlen($champ_code_barres) == 3) ? $champ_code_barres : '995';
$zone = (strlen($champ_code_barres) == 3) // legacy: before 'champ_type_doc' could equal '996' or '852', which has been deprecated by introduction of 'item_zone'. Need to check if some sites in production still uses these values (some tests does...)
? $champ_code_barres
: $zone;
$z995r = $this->get_subfield($zone,
$this->profil['attributs'][0]['champ_type_doc']);
} else {
$z995r = $this->get_subfield('995', 'r');
$z995p = $this->get_subfield('995', 'p');
$z995r = $this->get_subfield($zone, 'r');
$z995p = $this->get_subfield($zone, 'p');
if($champ_code_barres == '997')
$z995r = $this->get_subfield('997', 't');
elseif($champ_code_barres == '852')
......
......@@ -244,4 +244,52 @@ class PMBIntegrationSerialsTest extends PMBIntegrationRecordsTestCase {
$this->assertEquals('Revue française de pédagogie',
Class_Notice::findFirstBy(['type_doc' => 2])->getTitreChapeau());
}
}
class PMBIntegrationSerialsBretagneSacreeTest extends PMBIntegrationRecordsTestCase {
public function getProfilDonnees() {
return Class_IntProfilDonnees::forPMB()
->setIdProfil(115)
->setAccents(Class_IntProfilDonnees::ENCODING_UTF8)
->setTypeDocField('e')
->setBarCodeField('f')
->setItemZone(996)
->setTypeDocRecognition(Class_TypeDoc::PERIODIQUE, '', 'PERIODIQUE')
->getRawAttributes();
}
public function setUp() {
parent::setUp();
$this->loadRecordsFromFile('unimarc_bretagne_sacree');
}
/** @test */
public function numberOfRecordsShouldBeTwentyOne() {
$this->assertEquals(21, Class_Notice::countBy([]));
}
/** @test */
public function numberOfPeriodiqueTitleShouldBeTwo() {
$records = Class_Notice::findAllBy(['type_doc' => 'per_title']);
$this->assertEquals(2, Class_Notice::countBy(['type_doc' => 'per_title']));
}
/** @test */
public function numberOfPeriodiqueArticleShouldBeEighteen() {
$this->assertEquals(18, Class_Notice::countBy(['type_doc' => 'per_art']));
}
/** @test */
public function numberOfPeriodiqueShouldBeOne() {
$this->assertEquals(1, Class_Notice::countBy(['type_doc' => 2]));
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -376,7 +376,7 @@ class Class_FileManager_FileSystem {
$found = array_slice($found, 0, Class_FileManager_FileSystem::LISTING_LIMIT);
}
return array_filter(array_map([Class_FileManager, 'find'], $found));
return array_filter(array_map([Class_FileManager::class, 'find'], $found));
};
return (new Storm_Cache())
......
......@@ -984,6 +984,11 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
}
public function setItemZone($value) {
return $this->setItemField(self::FIELD_ITEM_ZONE, $value);
}
public function getBarCodeField() {
return unserialize($this->getAttributs())[0][self::FIELD_ITEM_BARCODE];
}
......
Markdown is supported
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