diff --git a/VERSIONS b/VERSIONS index a03b66ba904dc260fe7d9fb1b927199ae600aa95..7e072e369ed83177c6216ba45d3c47d5445e8e2e 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,7 +1,21 @@ +31/08/2015 - v7.3.4 + + - ticket #28796 : correction de la duplication d'entrées dans les facettes dynamiques si le libellé du champ à indexer est supérieur à 20 caractères + + - ticket #27951: Supprimer un album supprime la notice associée + + - ticket #28245: Corrige l'affichage aléatoire des critiques + + - ticket #24497 : correction de l'indexation des domaines + + + 26/07/2015 - v7.3.3 - Fixe le merge du ticket #27657 + + 25/08/2015 - v7.3.2 - ticket #11217 : indexation à la volée des notices de la bibliothèque numérique. diff --git a/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php b/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php index 5ad208a1136953d84050d0f3d6ddcded430669e6..83f599228d802de64d8977fae24a2d8fd518226a 100644 --- a/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php +++ b/cosmogramme/cosmozend/application/modules/cosmo/controllers/FacetsController.php @@ -64,10 +64,10 @@ class Cosmo_FacetsController extends Zend_Controller_Action { if (!$model->getIdThesaurus()) { $libelle = preg_replace('/[^a-zA-Z0-9]/', '', $this->_getParam('libelle_facette')); - $libelle = substr($libelle, 0, 4); + $id_thesaurus = $this->generateNewIdThesaurusForLabel($libelle); $model->setIdThesaurus($id_thesaurus); - $model->setCode($libelle); + $model->setCode($id_thesaurus); } $model->save(); @@ -76,10 +76,16 @@ class Cosmo_FacetsController extends Zend_Controller_Action { protected function generateNewIdThesaurusForLabel($label) { + $id = substr(strtoupper($label), 0, 4); + + if (strlen($id) == 4 && !Class_CodifThesaurus::findFirstBy(['id_thesaurus' => $id])) + return $id; + + $label = substr(strtoupper($label), 0, 3); $suffixes = array_merge(range(0, 9), range('a', 'z')); while(!empty($suffixes)) { $suffix = strtoupper(array_shift($suffixes));; - $id = sprintf("%'".$suffix."-4s", strtoupper($label)); + $id = sprintf("%'".$suffix."-4s", $label); if (!Class_CodifThesaurus::findFirstBy(['id_thesaurus' => $id])) return $id; } diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php index 3bc761728f3eb7e16fd896a662cc8ce38f0d8043..c1e3cd08033938ccd23790f327eabcf1e2b72cba 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DynamicFacetsControllerTest.php @@ -189,6 +189,24 @@ class Cosmo_DynamicFacetsControllerValidateTest extends Cosmo_DynamicFacetsContr } + /** @test */ + public function withExistingIdThesaurusDOCUNewIdThesaurusShouldBeDOC0() { + $this->fixture('Class_CodifThesaurus', + ['libelle' => 'doc that i love', + 'id_thesaurus' => 'DOCU', + 'rules' => '{"label":" 345$t "}']); + + $this->postDispatch( + '/cosmo/facets/validate', + ['libelle_facette' => 'docu', + 'rules' => '33$2']); + + $this->assertEquals('DOC0', + Class_CodifThesaurus::findFirstBy(['libelle'=>'docu'])->getIdThesaurus()); + + } + + /** @test */ public function withSpecialCharsNewIdThesaurusShouldBeFourLetters() { $this->postDispatch( diff --git a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php index 80a9e619915f5f63b5422d69f5524503f68ca87c..a665b4e31a7e164c3cbea62f5146d005f80d0908 100644 --- a/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php +++ b/cosmogramme/tests/php/classes/KohaRecordIntegrationTest.php @@ -201,6 +201,22 @@ class KohaRecordIntegrationVagabondWithThesaurusOn702DollarATest extends KohaRec 'code' => 'document', 'rules' => '{"label":" 99$t "}']); + $this->fixture('Class_CodifThesaurus', + ['id' => 4, + 'libelle' => 'Summary', + 'id_thesaurus' => 'SUMM', + 'id_origine' => null, + 'code' => 'summary', + 'rules' => '{"label":" 200$g "}']); + + $this->fixture('Class_CodifThesaurus', + ['id' => 5, + 'libelle' => 'd\'après l\'oeuvre d\'Eiji Yoshikawa, "Miyamoto Musashi"', + 'id_thesaurus' => 'SUMM0001', + 'id_origine' => 'D\'APRèS L\'OEUVRE D\'', + 'code' => 'summary' + ]); + $loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifThesaurus'); $loader @@ -227,6 +243,11 @@ class KohaRecordIntegrationVagabondWithThesaurusOn702DollarATest extends KohaRec $this->assertEquals('Vagabond n° 4', $this->_notice->getTitrePrincipal()); } + /** @test */ + public function noSumm0002ShouldBeCreated() { + $entry = Class_CodifThesaurus::findAllBy(['libelle' => 'd\'après l\'oeuvre d\'Eiji Yoshikawa, "Miyamoto Musashi"']); + $this->assertCount(1, $entry); + } /** @test */ public function facetsShouldContainsHAUTH0001() { diff --git a/library/Class/Album.php b/library/Class/Album.php index c40311f73b402f77d25a86301e5ba2c675f41785..d8d80d4a6edb29a12d6faed4b734292ce5a29e0d 100644 --- a/library/Class/Album.php +++ b/library/Class/Album.php @@ -896,7 +896,8 @@ class Class_Album extends Storm_Model_Abstract { public function beforeDelete() { parent::beforeDelete(); - $this->deleteFiles(); + $this->deleteRecord() + ->deleteFiles(); } @@ -972,6 +973,14 @@ class Class_Album extends Storm_Model_Abstract { } + public function deleteRecord() { + if ($notice = $this->getNotice()) + $notice->delete(); + + return $this; + } + + /** * Ceci échouera si les reps ne sont pas vides */ diff --git a/library/Class/CodifThesaurus.php b/library/Class/CodifThesaurus.php index 577b426e147bd51113ea33a0260f11a02804b7e4..a1673822ff501bb5b17f11e84dd7052aec512053 100644 --- a/library/Class/CodifThesaurus.php +++ b/library/Class/CodifThesaurus.php @@ -163,12 +163,16 @@ class Class_CodifThesaurusLoader extends Storm_Model_Loader { class Class_CodifThesaurus extends Storm_Model_Abstract { - const CODE_FACETTE = 'H'; - const CODE_CATALOGUE = 'Catalogue'; - const MODE_HIERARCHY_CONTAINS = 1; - const MODE_LABEL_STARTS_WITH = 2; - const MODE_LABEL_CONTAINS = 3; - const MODE_INDEX_STARTS_WITH = 4; + const + COLUMN_ORIGIN_SIZE = 20, + + CODE_FACETTE = 'H', + CODE_CATALOGUE = 'Catalogue', + + MODE_HIERARCHY_CONTAINS = 1, + MODE_LABEL_STARTS_WITH = 2, + MODE_LABEL_CONTAINS = 3, + MODE_INDEX_STARTS_WITH = 4; protected $_loader_class = 'Class_CodifThesaurusLoader'; protected $_table_name = 'codif_thesaurus'; @@ -240,7 +244,7 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { public function getOrCreateChild($id_origine, $label) { if (!$entry = $this->getLoader()->findFirstBy(['code' => $this->getCode(), - 'id_origine' => $id_origine])) { + 'id_origine' => substr($id_origine, 0, self::COLUMN_ORIGIN_SIZE)])) { $entry = $this ->newChildEntry() ->updateAttributes(['id_origine' => $id_origine, diff --git a/library/ZendAfi/View/Helper/Accueil/Critiques.php b/library/ZendAfi/View/Helper/Accueil/Critiques.php index fc8710fc050e40c82524ab8c47ddfd76ee330c0a..1c0e147fea217f93a7c4de0315a1e7ef0d0c29c7 100644 --- a/library/ZendAfi/View/Helper/Accueil/Critiques.php +++ b/library/ZendAfi/View/Helper/Accueil/Critiques.php @@ -22,6 +22,8 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_Base { public function getHtml() { + $this->contenu = ''; + if ($this->isHierarchicalDisplay()) { $this->titre = $this->getPreference('titre'); $this->contenu = $this->view->domainTree($this->getPreference('id_catalogue'), @@ -36,7 +38,8 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_ $fetched_avis = Class_AvisNotice::getAvisFromPreferences($this->getPreferences()); - if ($this->getPreferences('display_order') == 'Random') + + if ($this->getPreference('display_order') == 'Random') shuffle($fetched_avis); $selected_avis = []; @@ -53,6 +56,7 @@ class ZendAfi_View_Helper_Accueil_Critiques extends ZendAfi_View_Helper_Accueil_ $selected_avis[] = $avis; } + if (count($selected_avis) == 0) { $this->contenu = $this ->decorateContenu($this->_tag('p', $this->_('Aucune critique récente'))); diff --git a/library/startup.php b/library/startup.php index 6c43d74cfef274ca16d259930e55b2845ccf7e9e..ef973914e19bf64ec9b05d372d87bb663eabdb31 100644 --- a/library/startup.php +++ b/library/startup.php @@ -64,7 +64,7 @@ function defineConstant($name, $value) { function setupConstants() { defineConstant('BOKEH_MAJOR_VERSION','7.3'); - defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.3'); + defineConstant('BOKEH_RELEASE_NUMBER', BOKEH_MAJOR_VERSION . '.4'); defineConstant('ROOT_PATH', realpath(dirname(__FILE__).'/..').'/'); diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index 6cf9da6f8235f67cfb789e0604fe27062d859a7b..8abcfa74c5769cdccb914b95598d66d99f9fe6e3 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -1113,7 +1113,8 @@ class NoticeAjaxControllerVideoMorceauTest extends AbstractControllerTestCase { * @test */ public function responseShouldContainsPlayer() { - $this->assertXPath('//param[@name="movie"][contains(@value,"//youtube.googleapis.com/v/axb2sHpGwHQ&source=uds&autoplay=1")]'); + $this->assertXPath('//param[@name="movie"][contains(@value,"//youtube.googleapis.com/v/u-9koO1cQEI&source=uds&autoplay=1")]', + $this->_response->getBody()); } diff --git a/tests/library/Class/AlbumTest.php b/tests/library/Class/AlbumTest.php index 8ce133cf0ec2f9beeab8f17e05b432f2d2bd0a91..5206811c290963098c5ec79ebb9b9f682027683c 100644 --- a/tests/library/Class/AlbumTest.php +++ b/tests/library/Class/AlbumTest.php @@ -681,4 +681,41 @@ class AlbumHarlockSortingResourcesTest extends AlbumHarlockTestCase { } } + + + +class AlbumDeletingTestCase extends Storm_Test_ModelTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture('Class_Album', + ['id' => 12066, + 'notice_id' => 3255060, + 'type_doc_id' => Class_TypeDoc::NUMILOG, + 'titre' => 'Le chemin de l\'esperance']); + + $this->fixture('Class_Notice', + ['id' => 3255060, + 'id_notice' => 3255060, + 'alpha_titre' => 'CHEMIN DE L ESPERANCE']); + + + Class_Album::find(12066)->delete(); + } + + + /** @test */ + public function albumChemindeLesperanceShouldBedeleted() { + $this->assertNull(Class_Album::find(12066)); + } + + + /** @test */ + public function deletingAlbumChemindeLesperanceShouldDeleteItsRecord() { + $this->assertNull(Class_Notice::find(3255060)); + } +} + ?> \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php index 9d23a82a514427036896b6c29a50bb607635fc55..bf7f3fc7839e041e136fbe368ddd5d537feeb02d 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/CritiquesTest.php @@ -51,17 +51,19 @@ class CritiquesAvisEmptyTest extends ViewHelperTestCase { abstract class CritiquesAvisTestCase extends ViewHelperTestCase { - protected $_storm_default_to_volatile = true; - protected $_prefs = []; // subclass responsibility + protected + $_storm_default_to_volatile = true, + $_helper, + $_prefs = []; // subclass responsibility public function setUp() { parent::setUp(); $this->_prepareFixtures(); - $helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $this->_prefs); - $helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->html = $helper->getBoite(); + $this->_helper = new ZendAfi_View_Helper_Accueil_Critiques(2, $this->_prefs); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->html = $this->_helper->getBoite(); } @@ -169,6 +171,16 @@ class CritiquesWithVignettesTest extends CritiquesAvisTestCase { } + /** @test */ + public function criticsOrderShouldBeRandom() { + Storm_Cache::setDefaultZendCache(null); + $htmls = []; + foreach(range(0, 9) as $i) + $htmls [] = $this->_helper->getBoite(); + + $this->assertTrue(count(array_unique($htmls)) > 1); + } + /** @test */ public function superLoloCommentWithHtmlShouldBeCutAfterTresBien() { $this->assertXPathContentContains($this->html, '//p', '