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

Merge branch 'hotline#38162_erreur_de_calcul_de_facettes_et_lien_de_facette' into 'stable'

Hotline#38162 erreur de calcul de facettes et lien de facette

See merge request !1649
parents 769caec3 d538358a
Branches
Tags
3 merge requests!1659Master,!1657Master,!1656Hotline master
- ticket #38162 : les facettes ne sont plus tronquées lors de l'indexation des domaines lorsque le champ correspondant a plus de 255 caractères
\ No newline at end of file
<?php
error_reporting(E_ERROR | E_PARSE);
define("PATCH_LEVEL","289");
define("PATCH_LEVEL","290");
define("APPLI","cosmogramme");
define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs");
......
<?php
$adapter = Zend_Db_Table::getDefaultAdapter();
try {
$adapter->query("DROP FUNCTION clean_spaces");
} catch(Exception $e) {}
$adapter->query("CREATE FUNCTION clean_spaces(str TEXT) RETURNS TEXT DETERMINISTIC
BEGIN
while instr(str, ' ') > 0 do
set str := replace(str, ' ', ' ');
end while;
return trim(str);
END");
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* 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
*/
require_once 'NoticeIntegrationTest.php';
abstract class NoticeIntegrationAloesTestCase extends NoticeIntegrationTestCase {
public function getProfilDonnees() {
return Class_IntProfilDonnees::forALOES()
->setIdProfil(111)
->getRawAttributes();
}
}
class NoticeIntegrationAloes11septembre2001Test extends NoticeIntegrationAloesTestCase {
public function getProfilDonnees() {
return Class_IntProfilDonnees::forALOES()
->setAttributs(serialize(
[ [
'type_doc' => [
[ 'code' => '0', 'label' => '', 'zone_995' => '' ],
[ 'code' => '1', 'label' => 'am;na', 'zone_995' => 'LIV;MS' ],
[ 'code' => '2', 'label' => 'as', 'zone_995' => 'PER'],
[ 'code' => '3', 'label' => 'i;j', 'zone_995' => 'CD;LIVCD;LIVK7;K7'],
[ 'code' => '4', 'label' => 'g','zone_995' => 'DVD'],
[ 'code' => '5', 'label' => 'l;m', 'zone_995' => 'CDR'],
[ 'code' => '6', 'label' => 'cm', 'zone_995' => 'PAR'],
[ 'code' => '7', 'label' => '', 'zone_995' => 'BRO' ],
[ 'code' => '8', 'label' => '', 'zone_995' => 'DOS'],
[ 'code' => '9', 'label' => '', 'zone_995' => ''],
[ 'code' => '10', 'label' => '', 'zone_995' => 'WEB;MF'],
[ 'code' => '11', 'label' => '', 'zone_995' => 'MET'],
[ 'code' => '12', 'label' => '', 'zone_995' => 'JEU'],
[ 'code' => '13', 'label' => '', 'zone_995' => 'CAR'],
[ 'code' => '14', 'label' => '', 'zone_995' => 'DDD'],
[ 'code' => '15', 'label' => '', 'zone_995' => 'DIA'],
[ 'code' => '16', 'label' => '', 'zone_995' => 'DIS'],
[ 'code' => '17', 'label' => '', 'zone_995' => 'CDJ'],
[ 'code' => '18', 'label' => '', 'zone_995' => 'LDVD'],
[ 'code' => '19', 'label' => '', 'zone_995' => 'LIA'],
[ 'code' => '20', 'label' => '', 'zone_995' => 'LIS'],
[ 'code' => '21', 'label' => '', 'zone_995' => 'TXT'],
[ 'code' => '22', 'label' => '', 'zone_995' => ''],
[ 'code' => '23', 'label' => '', 'zone_995' => 'VDD;VID;UMATIC'],
[ 'code' => '24', 'label' => '', 'zone_995' => 'METI'],
],
'champ_code_barres' => 'f',
'champ_cote' => 'k',
'champ_type_doc' => 'r',
'champ_genre' => '',
'champ_section' => 'q',
'champ_emplacement' => 'u',
'champ_annexe' => 'b'
],
[ 'champs' => ''],
[ 'champs' => ''],
[ 'champs' => ''],
[ 'champs' => '', 'xml_balise_abonne' => '', 'xml_champs_abonne' => [ 'IDABON' => '',
'ORDREABON' => '',
'NOM' => '',
'PRENOM' => '',
'NAISSANCE' => '',
'PASSWORD' => '',
'MAIL' => '',
'DATE_DEBUT' => '',
'DATE_FIN' => '',
'ID_SIGB' => '' ] ],
[ 'zone' => '995', 'champ' => 'v', 'format' => '3', 'jours' => '', 'valeurs' => 'n']
]))
->setIdProfil(111)
->getRawAttributes();
}
public function setUp() {
parent::setUp();
$this->fixture('Class_CosmoVar',
['id' => 'nature_docs',
'liste' => "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image"]);
$this->fixture('Class_CosmoVar',
['id' => 'types_docs',
'liste' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n15:Liseuse\r\n21:Texte audio\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"]);
}
/** @test */
public function notice11Septembre2001ShouldHaveTypeDoc21() {
$this->loadNotice('unimarc_11_septembre_2001');
$notice = Class_Notice::find(1);
$this->assertEquals(21, $notice->getTypeDoc());
}
}
class NoticeIntegrationAloesSiesteMamansTest extends NoticeIntegrationAloesTestCase {
public function setUp() {
parent::setUp();
$this->loadNotice('unimarc_sieste_des_mamans');
$this->loadNotice('unimarc_sieste_des_mamans');
}
/** @test */
public function EuroSymbolShouldBeWellEncoded() {
$unimarc = new Class_NoticeUnimarc();
$unimarc->setNotice(Class_Notice::find(1)->getUnimarc());
$this->assertEquals('12 €', $unimarc->get_subfield('010', 'd')[0]);
}
}
class NoticeIntegrationAloesPommeDeReinetteTest extends NoticeIntegrationAloesTestCase {
public function getProfilDonnees() {
return Class_IntProfilDonnees::forALOES()
->setIdProfil(111)
->setItemField(Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT, 'u')
->getRawAttributes();
}
public function setUp() {
parent::setUp();
VariableCache::getInstance()
->setListeCache([
'nature_docs'=> "1:Collection\r\n2:Dataset\r\n3:Event\r\n4:Image",
'types_docs' => "0:non identifié\r\n1:livres\r\n2:périodiques\r\n3:disques\r\n4:DVD\r\n5:cédéroms\r\n8:articles cms\r\n9:fils rss\r\n10:sites internet\r\n15:Liseuse\r\n21:Texte audio\r\n100:Livre Numérique\r\n101:Diaporamas\r\n102:Type doc\r\n103:OAI\r\n104:Type doc\r\n105:Formation Vodéclic\r\n106:Livres Numériques\r\n107:Vidéos à la demande\r\n108:Tout apprendre\r\n109:Enregistrement audio\r\n110:Numérique Premium"
]);
$this->fixture('Class_CodifEmplacement',
['id' => 46,
'libelle' => 'Espace Bébé',
'regles' => '995$u=59;Espace bébé']);
$this->loadNotice('unimarc_pomme_de_reinette');
$this->_notice = Class_Notice::find(1);
$this->_exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => 1,
'code_barres' => '1203195946']);
}
/** @test */
public function exemplaireShouldHaveEmplacementE46() {
$this->assertEquals(46, $this->_exemplaire->getEmplacement());
}
/** @test */
public function facettesShouldContainsE46() {
$this->assertContains(' E46', $this->_notice->getFacettes());
}
}
class NoticeIntegrationAloesSerialIndexpressBellesHistoireTest extends NoticeIntegrationAloesTestCase {
public function setUp() {
parent::setUp();
$contents = file_get_contents(dirname(__FILE__)."/unimarc_petit_doucet.txt");
array_map([$this, 'loadNoticeFromString'],
preg_split('/'.chr(30).chr(29).'/', $contents));
$this->notice = Class_Notice::find(1);
}
/** @test */
public function mainTitleShouldBeBellesHistoires() {
$this->assertEquals('Belles histoires (Les)', $this->notice->getTitrePrincipal());
}
/** @test */
public function noArticleShouldHaveBeenSaved() {
$this->assertCount(0, Class_Notice_SerialArticles::findAll());
}
}
class NoticeIntegrationAloesBienveillantesTest extends NoticeIntegrationAloesTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_CodifEmplacement',
['id' => 2,
'libelle' => 'Reserve',
'regles' => '995$l=RES']);
$this->loadNotice("unimarc_bienveillantes");
}
/** @test */
public function recordShouldContainsSixItems() {
$this->assertEquals(6, count($this->notice_data['exemplaires']));
}
/** @test */
public function locationForFirstItemShouldNotHaveId2() {
$this->assertNotEquals(2, $this->notice_data['exemplaires'][0]['emplacement']);
}
/** @test */
public function thirdItemShouldHaveId2() {
$this->assertEquals(2, $this->notice_data['exemplaires'][2]['emplacement']);
}
}
class NoticeIntegrationAloesZanzibarTest extends NoticeIntegrationAloesTestCase {
public function setUp() {
parent::setUp();
$this->loadNotice("unimarc_zanzibara");
}
/** @test */
public function subfield200AShouldBeZanzibaraVol8() {
$this->assertEquals('Zanzibara, vol. 8',
$this->notice_integration->get_subfield('200', 'a')[0]);
}
/** @test */
public function subfield345AShouldBeGAM() {
$this->assertEquals('GAM',
$this->notice_integration->get_subfield('345', 'a')[0]);
}
/** @test */
public function subfield330ShouldContainsRajabSuleiman() {
$this->assertContains('L\'as du qanun Rajab Suleiman',
$this->notice_integration->get_subfield('330', 'a')[0]);
}
}
class NoticeIntegrationAloesDimancheALaPiscineTest extends NoticeIntegrationAloesTestCase {
public function getProfilDonnees() {
return Class_IntProfilDonnees::forALOES()
->setIdProfil(111)
->setItemField(Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT, 'u')
->getRawAttributes();
}
public function setUp() {
parent::setUp();
$this->notice_sgbd=new notice_unimarc();
$this->fixture('Class_CodifEmplacement',
['id' => 54,
'libelle' => 'adulte',
'regles' => '995$u=Littérature adulte']);
$this->fixture('Class_CodifSection',
['id' => 2,
'libelle' => 'adulte',
'regles' => '995$q=A']);
$this->fixture('Class_CodifGenre',
['id' => 8,
'libelle' => 'roman',
'regles' => '902$a=Roman']);
$this->fixture('Class_CodifAnnexe', ['code' => 'A',
'libelle' => 'Antibes',
'id_bib' => 4,
'invisible' => 0]);
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Exemplaire');
$this->loadNotice("unimarc_dimanche_a_la_piscine");
}
/** @test */
public function emplacementShouldHaveId54() {
$this->assertEquals(54, $this->notice_data['exemplaires'][0]['emplacement']);
}
/** @test */
public function sectionShouldHaveId2() {
$this->assertEquals(2, $this->notice_data['exemplaires'][0]['section']);
}
/** @test */
public function genreShouldHaveId8() {
$this->assertEquals(8, $this->notice_data['exemplaires'][0]['genre']);
}
/** @test */
public function deweyShouldContainsRoman() {
$this->assertContains('ROMAN',
Class_Notice::find(1)->getDewey());
}
/** @test */
public function exemplairesCountShouldBeOne() {
$this->assertEquals(1, count($this->notice_data['exemplaires']));
}
/**
* @test
* @see #13453
*/
public function uniciteCodeBarreShouldNotRegress() {
$this->assertEquals(
[
'id_notice' => 1,
'id_int_bib' => 1,
'code_barres' => [2060303]
],
Class_Exemplaire::getLoader()->getFirstAttributeForLastCallOn('deleteBy')
);
}
/** @test */
public function exemplaireShouldHaveBeenSavedForNotice1() {
$exemplaire = Class_Exemplaire::findFirstBy(['id_notice' => 1]);
$this->assertNotEmpty($exemplaire);
return $exemplaire;
}
/**
* @test
* @depends exemplaireShouldHaveBeenSavedForNotice1
*/
public function exemplaireIdOrigineShouldBe0419704($exemplaire) {
$this->assertEquals('0419704', $exemplaire->getIdOrigine());
}
/**
* @test
* @depends exemplaireShouldHaveBeenSavedForNotice1
*/
public function exemplaireAnnexeShouldBeAntibes($exemplaire) {
$this->assertEquals('A', $exemplaire->getAnnexe());
}
/**
* @test
* @depends exemplaireShouldHaveBeenSavedForNotice1
*/
public function exemplaireIdBibShouldBeFour($exemplaire) {
$this->assertEquals(4, $exemplaire->getIdBib());
}
/**
* @test
* @depends exemplaireShouldHaveBeenSavedForNotice1
*/
public function exemplaireIdIntBibShouldBeOne($exemplaire) {
$this->assertEquals(1, $exemplaire->getIdIntBib());
}
/** @test */
public function noticeOneDateMajShouldBeToday() {
$this->assertContains(date('Y-m-d'), Class_Notice::find(1)->getDateMaj());
}
/** @test */
public function supprimerExemplaireShouldRemoveIt() {
$this->notice_integration->supprimerExemplaire(1, ['code_barres' => '2060303']);
Class_Exemplaire::clearCache();
$this->assertEmpty(Class_Exemplaire::findFirstBy(['id_notice' => 1]));
}
/** @test */
public function supprimerExemplaireWithUnknownCodeBarresShouldSetError() {
$this->notice_integration->supprimerExemplaire(1, ['code_barres' => '666']);
$this->assertEquals(['statut' => 0,
'erreur' => 'code-barres à supprimer non trouvé',
'warnings' => [],
'identification' => 'non trouvée'],
$this->notice_integration->getLastStatut());
}
/** @test */
public function supprimerExemplaireWithNoIdNoticeShouldSetError() {
$this->notice_integration->supprimerExemplaire(0, []);
$this->assertEquals(['statut' => 0,
'erreur' => 'notice de l\'exemplaire à supprimer non trouvée',
'warnings' => [],
'identification' => 'non trouvée'],
$this->notice_integration->getLastStatut());
}
}
class NoticeIntegrationAloesBiblioArcheoAnimauxTest extends NoticeIntegrationAloesTestCase {
public function setUp() {
parent::setUp();
$this->loadNotice('unimarc_archeo_animaux');
$this->notice_sgbd->ouvrirNotice($this->notice_integration->noticeToDBEnreg($this->notice_data)['unimarc'], 0);
}
/** @test */
public function typeDocShouldBeOne() {
$this->assertEquals(1,
$this->notice_integration->noticeToDBEnreg($this->notice_data)['type_doc']);
}
/** @test */
public function field200AShouldBeAsExpected() {
$this->assertEquals('Archéo animaux',$this->notice_sgbd->get_subfield('200', 'a')[0]);
}
/** @test */
public function field200EShouldBeAsExpected() {
$this->assertEquals("l'incroyable histoire de l'archéologie des animaux",$this->notice_sgbd->get_subfield('200', 'e')[0]);
}
/** @test */
public function field200FShouldBeLamysHachem() {
$this->assertEquals('Lamys Hachem',$this->notice_sgbd->get_subfield('200', 'f')[0]);
}
/** @test */
public function field200GShouldBeLamysHachem() {
$this->assertEquals("ill. d'Hélène Georges",$this->notice_sgbd->get_subfield('200', 'g')[0]);
}
/** @test */
public function firstField210AShouldBeAsExpected() {
$this->assertEquals('Arles',$this->notice_sgbd->get_subfield('210', 'a')[0]);
}
/** @test */
public function secondField210AShouldBeAsExpected() {
$this->assertEquals('[Paris]',$this->notice_sgbd->get_subfield('210', 'a')[1]);
}
/** @test */
public function field210CShouldBeAsExpected() {
$this->assertEquals('Actes Sud junior',$this->notice_sgbd->get_subfield('210', 'c')[0]);
}
/** @test */
public function field210DShouldBeAsExpected() {
$this->assertEquals('2013',$this->notice_sgbd->get_subfield('210', 'd')[0]);
}
/** @test */
public function field215AShouldBeAsExpected() {
$this->assertEquals('1 vol. (84 p.)',$this->notice_sgbd->get_subfield('215', 'a')[0]);
}
/** @test */
public function field215CShouldBeAsExpected() {
$this->assertEquals('ill. en coul., couv. ill. en coul.',$this->notice_sgbd->get_subfield('215', 'c')[0]);
}
/** @test */
public function field215DShouldReturn28Cm() {
$this->assertEquals('28 cm',$this->notice_sgbd->get_subfield('215', 'd')[0]);
}
/** @test */
public function unimarc330ShoulBeAsExpected() {
$this->assertEquals('Documentaire d\'une très grande qualité qui permet d\'apprendre ce qu\'est l\'archéozoologie (l\'archéologie appliquée aux découvertes animales) et de découvrir les méthodes et techniques utilisées par les professionnels. Un livre enrichissant, à conseiller aux enfants comme aux adultes, pour en savoir plus sur les différents rôles des animaux auprès des hommes au fil des époques et l\'évolution des modes de vie, et découvrir les divers aspects du métier passionnant d\'archéozoologue. A noter : ce livre a remporté le prix « Le Goût des sciences 2013 », (catégorie « La science expliquée aux jeunes »).', $this->notice_sgbd->get_subfield('330', 'a')[0]);
}
}
?>
\ No newline at end of file
This diff is collapsed.
......@@ -515,4 +515,21 @@ class UpgradeDB_289_Test extends UpgradeDBTestCase {
$this->assertContains("\r\n2:aucun",
$this->query("select liste from variables where clef='mode_doublon'")->fetch()['liste']);
}
}
class UpgradeDB_290_Test extends UpgradeDBTestCase {
public function prepare() {}
/** @test */
public function cleanSpacesShouldNotTruncateAt255Characters() {
$facets = 'HSOUS0001 HSOUS0002 HLANG0001 A191462 A155897 A191463 A133747 A23754 A191464 A81181 A191465 A47146 A191466 A133767 A134066 A191467 A191468 A191469 A191470 A191471 A191472 A191473 A191474 A191475 A191476 A191477 A191478 A103360 A103361 A191479 A191480 A65390 Lfre Leng G60 G1 G5 T4 B1 S1 YROU HCCCC0002 HCCCC0002011500320011';
$this->assertEquals($facets,
$this->query('select clean_spaces("' . $facets . '") as facets')
->fetch()['facets']);
}
}
\ No newline at end of file
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