diff --git a/VERSIONS_HOTLINE/200741 b/VERSIONS_HOTLINE/200741 new file mode 100644 index 0000000000000000000000000000000000000000..4d8331ac962388a7f018192f808ed04a18d58b76 --- /dev/null +++ b/VERSIONS_HOTLINE/200741 @@ -0,0 +1 @@ + - correctif #200741 : Recherche : Optimisation de la recherche dans le cas d'utilisations de domaines et de filtres profil en simultané. \ No newline at end of file diff --git a/application/modules/admin/controllers/ModulesController.php b/application/modules/admin/controllers/ModulesController.php index 93e8c5ede6624092d57c82d3d0d3403ef44e2c63..03964a5834e1b3b97adb620c45dff54eb3a3a3e5 100644 --- a/application/modules/admin/controllers/ModulesController.php +++ b/application/modules/admin/controllers/ModulesController.php @@ -351,7 +351,7 @@ class Admin_ModulesController extends ZendAfi_Controller_Action { public function recordAction() { $codif = Class_Codification::getInstance(); $this->view->titre = $this->_('Configuration de l\'affichage du type %s', - $codif->getLibelleFacette(Class_CodifTypeDoc::CODE_FACETTE . $this->_getParam('action2'))); + $codif->getLibelleFacette(Class_TypeDoc::CODE_FACETTE . $this->_getParam('action2'))); $valid = $this->isValidPostNotice(); diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DeleteItemsControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DeleteItemsControllerTest.php index b65a34b5b7fe91a8eaa2f6781d3f1d3ed6cefb1f..c9927d8ad1c282bca891c485b03e95f32b11f3e0 100644 --- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DeleteItemsControllerTest.php +++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DeleteItemsControllerTest.php @@ -120,7 +120,7 @@ abstract class Cosmo_DeleteItemsControllerAllTestCase extends CosmoControllerTes ['id' => 1]); $this->fixture(Class_StatsNotices::class, ['id' => 1]); - $this->fixture(Class_CodifTags::class, + $this->fixture(Class_TagNotice::class, ['id' => 1]); $this->fixture(Class_Cosmogramme_Integration::class, ['id' => 1]); @@ -191,7 +191,7 @@ class Cosmo_DeleteItemsControllerAllRunDeleteArticleRecordsTest [2, Class_NoticeSuccincte::class], [3, Class_Exemplaire::class], [4, Class_StatsNotices::class], - [5, Class_CodifTags::class], + [5, Class_TagNotice::class], [6, Class_Cosmogramme_Integration::class], [7, Class_IntAnalyse::class], [8, Class_Pret::class], @@ -463,7 +463,7 @@ abstract class Cosmo_DeleteItemsControllerLibraryTestCase extends CosmoControlle 'clef_chapeau' => 'MY-KEY', 'clef_numero' => '001']); - $this->fixture(Class_CodifTags::class, + $this->fixture(Class_TagNotice::class, ['id' => 1]); } } diff --git a/cosmogramme/php/classes/classe_notice_integration.php b/cosmogramme/php/classes/classe_notice_integration.php index bc51c374ac526fdf4ca5c7514cd8e8ccd0d7d483..a9bbf583e8c4faedb1394ebbe6c1d4c57713b80e 100644 --- a/cosmogramme/php/classes/classe_notice_integration.php +++ b/cosmogramme/php/classes/classe_notice_integration.php @@ -924,7 +924,7 @@ class notice_integration { // Tags if ($id_notice) - foreach (Class_CodifTags::findForRecord($id_notice) as $tag) + foreach (Class_TagNotice::findForRecord($id_notice) as $tag) $facettes[] = $tag->asFacet(); // Doc type diff --git a/cosmogramme/sql/patch/patch_465.php b/cosmogramme/sql/patch/patch_465.php new file mode 100644 index 0000000000000000000000000000000000000000..26da0f1dd0df706cf42d42117fcdc6b69af66812 --- /dev/null +++ b/cosmogramme/sql/patch/patch_465.php @@ -0,0 +1,13 @@ +<?php +$adapter = Zend_Db_Table::getDefaultAdapter(); + +try +{ + $adapter->query('ALTER TABLE `codif_matiere` ADD INDEX IF NOT EXISTS (`libelle`);'); + + $adapter->query("UPDATE `codif_tags` SET `notices` = CLEAN_SPACES(REGEXP_REPLACE(`notices`, ';', ' '));"); + + $adapter->query("UPDATE `codif_tags` SET `a_moderer` = CLEAN_SPACES(REGEXP_REPLACE(`a_moderer`, ';', ' '));"); +} +catch (Exception $e) +{} diff --git a/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php b/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php index b4a4c25c004e8cce08f973e52bd5104c44a695df..cf5fd79718144e9bf4593f975368e3af91ed4d50 100644 --- a/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php +++ b/cosmogramme/tests/php/classes/NoticeIntegrationDedupTest.php @@ -103,16 +103,13 @@ class NoticeIntegrationDedupSameUnimarcLoadedTest extends NoticeIntegrationTestC $this->loadNotice('unimarc_dernier_des_hommes'); $record = Class_Notice::findFirstBy([]); - $this->tag = $this->fixture('Class_CodifTags', + $this->tag = $this->fixture(Class_TagNotice::class, ['id' => 1, 'code_alpha' => 'CDC', - 'notices' => ';' . $record->getId() . ';']); + 'notices' => $record->getId()]); $record->updateFacette($this->tag->asFacet()) ->save(); - $this->onLoaderOfModel('Class_CodifTags') - ->whenCalled('findForRecord')->with(1)->answers([$this->tag]); - $this->loadNotice('unimarc_dernier_des_hommes'); } diff --git a/library/Class/Bib.php b/library/Class/Bib.php index d77cc75afefc60922aa9c374a66ea83f383f6c72..fa95060f82da0e5f74f5619d8b03ab1ac8b0b8bc 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -21,8 +21,9 @@ require_once dirname(__FILE__)."/CompositeBuilder.php"; -class BibLoader extends Storm_Model_Loader { - use Trait_Translator; +class BibLoader extends Storm_Model_Loader +{ + use Trait_Translator, Trait_FacetableLoader; protected $_all_labels_cache, diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index 6033fc5c81415ceeae0c2308c57aa5a6ca0e942a..c889310e1786089a6b5745cd085c0de6a59d88e0 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -20,14 +20,15 @@ */ -class Class_Catalogue extends Storm_Model_Abstract { - +class Class_Catalogue extends Storm_Model_Abstract +{ use Trait_TreeNode, Trait_Translator, Trait_CustomFields, Trait_Facetable, - Trait_TimeSource; + Trait_TimeSource, + Trait_FacetableLoader; const CODE_FACETTE = 'Q', @@ -88,7 +89,6 @@ class Class_Catalogue extends Storm_Model_Abstract { $_from, $_until; - public function getParent() { return $this->getDomaineParent(); } @@ -231,9 +231,9 @@ class Class_Catalogue extends Storm_Model_Abstract { Class_CodifLangue::CODE_FACETTE => $this->getLangue(), Class_CodifAnnexe::CODE_FACETTE => $this->getAnnexe(), Class_CodifEmplacement::CODE_FACETTE => $this->getEmplacement(), - Class_CodifTypeDoc::CODE_FACETTE => $this->getTypeDoc(), + Class_TypeDoc::CODE_FACETTE => $this->getTypeDoc(), Class_CodifAuteur::CODE_FACETTE => $this->getAuteur(), - Class_CodifTags::CODE_FACETTE => $this->getTags(), + Class_TagNotice::CODE_FACETTE => $this->getTags(), Class_CodifCentreInteret::CODE_FACETTE => $this->getInteret(), Class_CodifMatiere::CODE_FACETTE => $this->getMatiereAndSousVedettes()]; @@ -303,22 +303,29 @@ class Class_Catalogue extends Storm_Model_Abstract { } - public function getMatiereAndSousVedettes() { - $matieres_str = $this->getMatiere(); - if (!$matieres_str) + public function getMatiereAndSousVedettes(): string + { + if ( ! ($matieres_ids = array_filter(explode(';', $this->getMatiere())))) return ''; - $matieres = explode(';',$matieres_str); - $valeur=''; - foreach ($matieres as $id_matiere) { - if (!$matiere = Class_Matiere::getLoader()->find($id_matiere)) - continue; - if ($valeur <> '') - $valeur .= ';'; - $valeur .= $id_matiere.';'; - if ('' != ($sous_vedettes = trim($matiere->getSousVedettes()))) - $valeur .= str_replace(' ', ';', $sous_vedettes); - } - return $valeur; + + $labels = array_map(fn($label) => trim($label['libelle']), + Class_Matiere::query() + ->distinct('libelle') + ->in('id_matiere', $matieres_ids) + ->beBasic() + ->fetchAll()); + + $sous_matieres_ids = []; + foreach (array_filter($labels) as $label) + $sous_matieres_ids = [...$sous_matieres_ids, + ...array_map(fn($id) => $id['id_matiere'], + Class_Matiere::query() + ->distinct('id_matiere') + ->start('libelle', $label . ' : ') + ->beBasic() + ->fetchAll())]; + + return implode(';', array_unique([...$matieres_ids, ...$sous_matieres_ids])); } diff --git a/library/Class/CharSet.php b/library/Class/CharSet.php index b2d24d7dcac068c34c15a4c8646f14303010dd59..81bc77c31fee162d5afb46de45894cd30a03e844 100644 --- a/library/Class/CharSet.php +++ b/library/Class/CharSet.php @@ -20,9 +20,11 @@ */ -class Class_CharSet { +class Class_CharSet +{ - public static function fromISOtoUTF8(?string $words) : string { + public static function fromISOtoUTF8(?string $words): string + { return iconv('ISO-8859-1', 'UTF-8', ($words ?? '')); } } diff --git a/library/Class/CodifAnnexe.php b/library/Class/CodifAnnexe.php index a88908e2c1352f8dfc406896bf9264258e799c0d..42bfda22f1a6066fb5ce9de220de5e240d7a4b10 100644 --- a/library/Class/CodifAnnexe.php +++ b/library/Class/CodifAnnexe.php @@ -19,8 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class CodifAnnexeLoader extends Storm_Model_Loader { - use Trait_Translator; + +class CodifAnnexeLoader extends Storm_Model_Loader +{ + use Trait_Translator, Trait_FacetableLoader; public function findAllByPickup() { return Class_CodifAnnexe::findAllBy(['no_pickup' => '0', @@ -72,6 +74,12 @@ class CodifAnnexeLoader extends Storm_Model_Loader { public function findFirstByLibrary(Class_Bib $library) : ?Class_CodifAnnexe { return Class_CodifAnnexe::findFirstBy(['id_bib' => $library->getId()]); } + + + protected function _criteriaOnQuery(Storm_Query $query, string $id): Storm_Query + { + return $query->eq('code', addslashes($id)); + } } @@ -93,20 +101,9 @@ class Class_CodifAnnexe extends Storm_Model_Abstract { 'no_pickup' => 0, 'date_maj' => '']; - - protected $_belongs_to = [ - 'bib' => ['model' => 'Class_Bib', - 'referenced_in' => 'id_bib'], - - 'int_bib' => ['through' => 'bib']]; - - - public static function facetLabelFor($id) { - return ($annexe = static::findFirstBy(['code' => addslashes($id)])) - ? $annexe->getLibelle() - : ''; - } - + protected $_belongs_to = ['bib' => ['model' => 'Class_Bib', + 'referenced_in' => 'id_bib'], + 'int_bib' => ['through' => 'bib']]; public function getMailIntBib() { return $this->hasIntBib() diff --git a/library/Class/CodifAuteur.php b/library/Class/CodifAuteur.php index 53b09436d09066516a11048411d071273c1a7853..a84cad59fd648525a247359bab544c574013855c 100644 --- a/library/Class/CodifAuteur.php +++ b/library/Class/CodifAuteur.php @@ -20,7 +20,10 @@ */ -class CodifAuteurLoader extends Storm_Model_Loader { +class CodifAuteurLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; + const RECORDS_LOAD_LIMIT = 100, AUTHORS_FETCH_BIO_LIMIT = 50; @@ -342,7 +345,8 @@ class CodifAuteurLoader extends Storm_Model_Loader { -class Class_CodifAuteur extends Storm_Model_Abstract { +class Class_CodifAuteur extends Storm_Model_Abstract +{ use Trait_Facetable; const CODE_FACETTE = 'A'; diff --git a/library/Class/CodifCentreInteret.php b/library/Class/CodifCentreInteret.php index 40d167fc4db2f89993c2b3b5e9980fdca3ddebf5..25fd7f48ea8b164c71f288a0e389d6da8e54be84 100644 --- a/library/Class/CodifCentreInteret.php +++ b/library/Class/CodifCentreInteret.php @@ -19,8 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_CodifCentreInteretLoader extends Storm_Model_Loader { - public function getListeSuggestion($value, $mode, $limit) { + +class Class_CodifCentreInteretLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; + + public function getListeSuggestion($value, $mode, $limit): array + { return (new Class_CodifSuggest(Class_CodifCentreInteret::getLoader())) ->suggest($value, $mode, $limit); } @@ -29,7 +34,8 @@ class Class_CodifCentreInteretLoader extends Storm_Model_Loader { -class Class_CodifCentreInteret extends Storm_Model_Abstract { +class Class_CodifCentreInteret extends Storm_Model_Abstract +{ use Trait_Facetable; const CODE_FACETTE = 'F'; diff --git a/library/Class/CodifDewey.php b/library/Class/CodifDewey.php index e9c13058372d8ee6e4c5cf1d9494939532067791..4e252035dfc35d1b6a091422a948dbef6e34fd5f 100644 --- a/library/Class/CodifDewey.php +++ b/library/Class/CodifDewey.php @@ -19,13 +19,22 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_CodifDeweyLoader extends Storm_Model_Loader { + +class Class_CodifDeweyLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; public function root() { return new Class_CodifDewey; } + protected function _default(string $id): string + { + return Class_CodifDewey::newInstance(['id_dewey' => $id])->formatIndice(); + } + + public function findNodesOfBy($instance, $params = []) { $children = $instance->getChildren($params); @@ -125,13 +134,6 @@ class Class_CodifDeweyLoader extends Storm_Model_Loader { } - public function getLibelleOf($indice) { - return ($dewey = Class_CodifDewey::find($indice)) - ? $dewey->getLibelle() - : Class_CodifDewey::newInstance(['id_dewey' => $indice])->formatIndice(); - } - - public function getIndices(string $pere) : array { $query = Class_CodifDewey::query() ->eq(Storm_Query_Key::length('id_dewey'), @@ -167,7 +169,8 @@ class Class_CodifDeweyLoader extends Storm_Model_Loader { -class Class_CodifDewey extends Storm_Model_Abstract { +class Class_CodifDewey extends Storm_Model_Abstract +{ use Trait_TreeNode, Trait_Facetable; const CODE_FACETTE = 'D'; @@ -177,12 +180,6 @@ class Class_CodifDewey extends Storm_Model_Abstract { protected $_loader_class = 'Class_CodifDeweyLoader'; protected $_fixed_id = true; - - public static function facetLabelFor($id) { - return static::getLoader()->getLibelleOf($id); - } - - public function beforeSave() { parent::beforeSave(); diff --git a/library/Class/CodifEmplacement.php b/library/Class/CodifEmplacement.php index 1e1c84c6bcb0f9e1f49c1ac599eee024e000559d..1044fe88f44c26a3a2db13656388bc480cfddc97 100644 --- a/library/Class/CodifEmplacement.php +++ b/library/Class/CodifEmplacement.php @@ -20,8 +20,12 @@ */ -class Class_CodifEmplacementLoader extends Storm_Model_Loader { - public function getLabel($id) { +class Class_CodifEmplacementLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; + + public function getLabel($id) + { return ($emplacement = Class_CodifEmplacement::find($id)) ? $emplacement->getLibelle() : ''; @@ -31,7 +35,8 @@ class Class_CodifEmplacementLoader extends Storm_Model_Loader { -class Class_CodifEmplacement extends Storm_Model_Abstract { +class Class_CodifEmplacement extends Storm_Model_Abstract +{ use Trait_Facetable, Trait_Translator; const CODE_FACETTE = 'E'; @@ -44,7 +49,6 @@ class Class_CodifEmplacement extends Storm_Model_Abstract { 'ne_pas_afficher' => 0, 'regles' => '',]; - public function isVisible() { return 0 == $this->getNePasAfficher(); } diff --git a/library/Class/CodifGenre.php b/library/Class/CodifGenre.php index 99efe3ffc6c07f11a2bab53101fa002f07e090f5..bd1f47e7889fa399f47aa1c00d4867670ea237e7 100644 --- a/library/Class/CodifGenre.php +++ b/library/Class/CodifGenre.php @@ -20,8 +20,9 @@ */ -class Class_CodifGenreLoader extends Storm_Model_Loader { - use Trait_Translator; +class Class_CodifGenreLoader extends Storm_Model_Loader +{ + use Trait_Translator, Trait_FacetableLoader; public function findOrCreateFromLabel($label) { if ($genre = $this->findFirstBy(['libelle' => $label])) @@ -64,7 +65,8 @@ class Class_CodifGenreLoader extends Storm_Model_Loader { -class Class_CodifGenre extends Storm_Model_Abstract { +class Class_CodifGenre extends Storm_Model_Abstract +{ use Trait_Facetable, Trait_Translator; const CODE_FACETTE = 'G'; @@ -79,13 +81,15 @@ class Class_CodifGenre extends Storm_Model_Abstract { 'regles' => '', 'date_maj' => '']; - - public function validate() { - $this->checkAttribute('libelle', '' != $this->getLibelle(), $this->_('Vous devez définir le libellé')); + public function validate() + { + $this->checkAttribute('libelle', '' != $this->getLibelle(), + $this->_('Vous devez définir le libellé')); } - public function getRulesLabel() { + public function getRulesLabel() + { return (new Class_Codification_Rules($this))->asHumanRead(); } } diff --git a/library/Class/CodifLangue.php b/library/Class/CodifLangue.php index 81473d079056a2033f85968f41537a1bed484f00..037ff6c421fe432fe0d4b656b1f2b6dea9fd1cad 100644 --- a/library/Class/CodifLangue.php +++ b/library/Class/CodifLangue.php @@ -20,18 +20,10 @@ */ -class Class_CodifLangueLoader extends Storm_Model_Loader { - protected $_id_without_match_cache = []; +class Class_CodifLangueLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; - public function find($id) { - if (in_array($id, $this->_id_without_match_cache)) - return null; - - if (!$model = parent::find($id)) - $this->_id_without_match_cache[] = $id; - - return $model; - } } @@ -47,7 +39,6 @@ class Class_CodifLangue extends Storm_Model_Abstract { $_table_primary = 'id_langue', $_loader_class = 'Class_CodifLangueLoader'; - /** * @param Array langues * @return array @@ -69,14 +60,6 @@ class Class_CodifLangue extends Storm_Model_Abstract { } - public static function facetLabelFor($id) { - return ($model = static::find($id)) - ? $model->getLibelle() - : ''; - } - - - public function getCategorie() { return; } diff --git a/library/Class/CodifMatiere.php b/library/Class/CodifMatiere.php index 9ebfe34a1ce3ee60e9916ae473f68181dd4a6e6c..3aae18e2343c5f459640db3b108480d8878756fa 100644 --- a/library/Class/CodifMatiere.php +++ b/library/Class/CodifMatiere.php @@ -19,8 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_CodifMatiereLoader extends Storm_Model_Loader { - public function findOrCreate($label) { + +class Class_CodifMatiereLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; + + public function findOrCreate($label) + { $code = substr(Class_Indexation::getInstance()->alphaMaj($label), 0, 255); if ($model = Class_CodifMatiere::findFirstBy(['code_alpha' => $code])) @@ -52,7 +57,8 @@ class Class_CodifMatiereLoader extends Storm_Model_Loader { -class Class_CodifMatiere extends Storm_Model_Abstract { +class Class_CodifMatiere extends Storm_Model_Abstract +{ use Trait_Facetable; const CODE_FACETTE = 'M'; @@ -65,9 +71,9 @@ class Class_CodifMatiere extends Storm_Model_Abstract { 'id_bnf' => '', 'date_creation' => '']; - - public function updateLabel($label) { - if($this->getLibelle() != $label) + public function updateLabel($label) + { + if ($this->getLibelle() != $label) $this->setLibelle($label)->save(); return $this; diff --git a/library/Class/CodifPcdm4.php b/library/Class/CodifPcdm4.php index 855d8c0df805a0383e6451eb0e05c08bfbfb6bf6..a0cb2490e3d42fef95006a1ad8ef898bbafe3177 100644 --- a/library/Class/CodifPcdm4.php +++ b/library/Class/CodifPcdm4.php @@ -19,11 +19,20 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_CodifPcdm4Loader extends Storm_Model_Loader { + +class Class_CodifPcdm4Loader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; + public function root() { return new Class_CodifPcdm4; } + protected function _default(string $id): string + { + return $id; + } + public function findParentOf($instance) { if (!$instance || $instance->isNew()) @@ -88,13 +97,6 @@ class Class_CodifPcdm4Loader extends Storm_Model_Loader { } - public function getLibelleOf($indice) { - return ($pcdm4 = Class_CodifPcdm4::find($indice)) - ? $pcdm4->getLibelle() - : $indice; - } - - public function filtreIndice($indice) { $indice=trim($indice); if(!is_numeric(substr($indice,0,1))) @@ -145,7 +147,8 @@ class Class_CodifPcdm4Loader extends Storm_Model_Loader { -class Class_CodifPcdm4 extends Storm_Model_Abstract { +class Class_CodifPcdm4 extends Storm_Model_Abstract +{ use Trait_Facetable, Trait_TreeNode; const CODE_FACETTE = 'P'; @@ -156,12 +159,6 @@ class Class_CodifPcdm4 extends Storm_Model_Abstract { $_loader_class = 'Class_CodifPcdm4Loader', $_fixed_id = true; - - public static function facetLabelFor($id) { - return static::getLoader()->getLibelleOf($id); - } - - public function getLibelle($id = null) { return ($libelle = parent::_get('libelle')) ? $libelle diff --git a/library/Class/CodifSection.php b/library/Class/CodifSection.php index 1705ac7451aaec58d645ead113ea8f2b37b63e40..0ad1b64595caf1673767d56679a1d41f2a9b0c17 100644 --- a/library/Class/CodifSection.php +++ b/library/Class/CodifSection.php @@ -19,8 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_CodifSectionLoader extends Storm_Model_Loader { - use Trait_Translator; + +class Class_CodifSectionLoader extends Storm_Model_Loader +{ + use Trait_Translator, Trait_FacetableLoader; public function labelsOfIds($ids) { if (empty($ids)) @@ -71,7 +73,8 @@ class Class_CodifSectionLoader extends Storm_Model_Loader { -class Class_CodifSection extends Storm_Model_Abstract { +class Class_CodifSection extends Storm_Model_Abstract +{ use Trait_Facetable, Trait_Translator; const CODE_FACETTE = 'S'; @@ -82,7 +85,6 @@ class Class_CodifSection extends Storm_Model_Abstract { protected $_default_attribute_values = ['invisible' => 0]; - public function getCategorie() { return; } diff --git a/library/Class/CodifThesaurus.php b/library/Class/CodifThesaurus.php index 82de5e8004729af94551f9f6bb4de669a30b5b48..e824d899a24ff754682a72781de1b4c1bf8f276b 100644 --- a/library/Class/CodifThesaurus.php +++ b/library/Class/CodifThesaurus.php @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_CodifThesaurus extends Storm_Model_Abstract { + +class Class_CodifThesaurus extends Storm_Model_Abstract +{ use Trait_Translator, Trait_MemoryCleaner, Trait_Facetable, Trait_TreeNode; const @@ -48,13 +50,6 @@ class Class_CodifThesaurus extends Storm_Model_Abstract { protected $_list_rules; - public static function facetLabelFor($id) { - return ($thesaurus = static::getLoader()->findFirstBy(['id_thesaurus' => $id])) - ? $thesaurus->getLibelleFacette() - : ''; - } - - public function beforeSave() { $this->setRules($this->_getListRules()->format()); } diff --git a/library/Class/CodifThesaurus/Loader.php b/library/Class/CodifThesaurus/Loader.php index 5b653d9b745fd914df9f6008cbfbf54c2a5bb1c6..9341c69a38c5ef444cdacab2b45b435f3bd091df 100644 --- a/library/Class/CodifThesaurus/Loader.php +++ b/library/Class/CodifThesaurus/Loader.php @@ -20,8 +20,9 @@ */ -class Class_CodifThesaurus_Loader extends Storm_Model_Loader { - use Trait_Translator; +class Class_CodifThesaurus_Loader extends Storm_Model_Loader +{ + use Trait_Translator, Trait_FacetableLoader; protected $_fixed = [], @@ -34,6 +35,21 @@ class Class_CodifThesaurus_Loader extends Storm_Model_Loader { } + public function facetLabelFor(string $id): string + { + if ( ! ($rows = $this->query() + ->select(['libelle_facette', 'libelle']) + ->eq('id_thesaurus', $id) + ->beBasic() + ->fetchFirst())) + return ''; + + return ($label = $rows['libelle_facette'] ?? '') + ? $label + : $rows['libelle'] ?? ''; + } + + public function findFixed($key) { return isset($this->_fixed[$key]) ? $this->_fixed[$key] diff --git a/library/Class/CodifTypeDoc.php b/library/Class/CodifTypeDoc.php index 7c08e7608909a5c074271475ed0f0ada2c4f00d0..7c1d17adf087e22143ac7d0503b92f2cbe17e37a 100644 --- a/library/Class/CodifTypeDoc.php +++ b/library/Class/CodifTypeDoc.php @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class CodifTypeDocLoader extends Storm_Model_Loader{ + +class CodifTypeDocLoader extends Storm_Model_Loader +{ use Trait_StaticFileSystem, Trait_Translator; protected $_zotero_schema; @@ -59,7 +61,6 @@ class CodifTypeDocLoader extends Storm_Model_Loader{ class Class_CodifTypeDoc extends Storm_Model_Abstract { use Trait_Translator; - const CODE_FACETTE = 'T'; const INCONNU = 0; const LIVRE = 1; const PERIODIQUE = 2; diff --git a/library/Class/Codification.php b/library/Class/Codification.php index 2cf0772027142134505cc16c49145529a4625f60..425534b9e0876118685c3f57d3cda76970a78b6a 100644 --- a/library/Class/Codification.php +++ b/library/Class/Codification.php @@ -57,6 +57,7 @@ class Class_Codification { use Trait_Singleton, Trait_Translator; + const SEPARATOR_FACET = '+'; const CHAMPS = 'JAKEFCNMDGHPILOR8QW56', CODE_COLLECTION = 'C', @@ -110,15 +111,15 @@ class Class_Codification { } - public function getLibelleFacette(string $rubrique) : string { + public function getLibelleFacette(string $rubrique): string + { if (isset(static::$_libelle_facette_cache[$rubrique])) return static::$_libelle_facette_cache[$rubrique]; $type = substr($rubrique, 0, 1); - if (!$id = substr($rubrique, 1)) + if ( ! $id = substr($rubrique, 1)) return static::$_libelle_facette_cache[$rubrique] = ''; - if (static::CODE_INDEX_DEWEY_PCDM4 == $type) return static::$_libelle_facette_cache[$rubrique] = $this->_deweyPcdm4LabelFor($id); @@ -135,7 +136,7 @@ class Class_Codification { Class_CodifEmplacement::CODE_FACETTE => Class_CodifEmplacement::class, Class_Bib::CODE_FACETTE => Class_Bib::class, Class_CodifAnnexe::CODE_FACETTE => Class_CodifAnnexe::class, - Class_CodifTags::CODE_FACETTE => Class_CodifTags::class, + Class_TagNotice::CODE_FACETTE => Class_TagNotice::class, Class_TypeDoc::CODE_FACETTE => Class_TypeDoc::class, ]; @@ -184,7 +185,7 @@ class Class_Codification { Class_CodifSection::CODE_FACETTE => [ $this->_('Section'), $this->_('Section')], Class_TypeDoc::CODE_FACETTE => [ $this->_('Type de document'),$this->_('Types de documents')], Class_CodifAnnexe::CODE_FACETTE => [ $this->_('Site'), $this->_('Site')], - Class_CodifTags::CODE_FACETTE => [ $this->_('Tag'), $this->_('Tag(s)')], + Class_TagNotice::CODE_FACETTE => [ $this->_('Tag'), $this->_('Tag(s)')], Class_Codification::CODE_URL => [ $this->_('Lien internet'), $this->_('Liens internet')], Class_Codification::CODE_AVAILABILITY => [ $this->_('En rayon'), $this->_('En rayon')], Class_Codification::CODE_NOUVEAUTE => [ $this->_('Nouveauté'), $this->_('Nouveauté')], @@ -212,7 +213,7 @@ class Class_Codification { 'FACETTE_AUTEUR_LIBELLE' => Class_CodifAuteur::CODE_FACETTE, 'FACETTE_INTERET_LIBELLE' => Class_CodifCentreInteret::CODE_FACETTE, 'FACETTE_MATIERE_LIBELLE' => Class_CodifMatiere::CODE_FACETTE, - 'FACETTE_TAG_LIBELLE' => Class_CodifTags::CODE_FACETTE]; + 'FACETTE_TAG_LIBELLE' => Class_TagNotice::CODE_FACETTE]; foreach($var_codes as $var => $code) { $label = Class_AdminVar::get($var); @@ -418,7 +419,7 @@ class Class_Codification { Class_CodifSection::CODE_FACETTE, Class_Bib::CODE_FACETTE, Class_CodifAnnexe::CODE_FACETTE, - Class_CodifTags::CODE_FACETTE, + Class_TagNotice::CODE_FACETTE, static::CODE_AVAILABILITY]; if (! Class_Template::current()->isLegacy()) @@ -455,7 +456,7 @@ class Class_Codification { Class_CodifMatiere::CODE_FACETTE, Class_CodifDewey::CODE_FACETTE, Class_CodifPcdm4::CODE_FACETTE, - Class_CodifTags::CODE_FACETTE]; + Class_TagNotice::CODE_FACETTE]; } @@ -464,7 +465,7 @@ class Class_Codification { Class_CodifMatiere::CODE_FACETTE, Class_CodifDewey::CODE_FACETTE, Class_CodifPcdm4::CODE_FACETTE, - Class_CodifTags::CODE_FACETTE, + Class_TagNotice::CODE_FACETTE, Class_CodifAnnexe::CODE_FACETTE]; } diff --git a/library/Class/Cosmogramme/Cleaner.php b/library/Class/Cosmogramme/Cleaner.php index c0f02b24f2f86864bdfe4f2da3f981a2eeb03cc9..592ebb72247090adff1283d974766efa4df69e93 100644 --- a/library/Class/Cosmogramme/Cleaner.php +++ b/library/Class/Cosmogramme/Cleaner.php @@ -54,7 +54,7 @@ class Class_Cosmogramme_Cleaner { static::SUCCINCTE => [Class_NoticeSuccincte::class, $this->_('suppression des notices succinctes')], static::ITEMS => [Class_Exemplaire::class, $this->_('suppression des exemplaires')], static::STATS => [Class_StatsNotices::class, $this->_('suppression des statistiques de notice')], - static::TAGS => [Class_CodifTags::class, $this->_('suppression des codifications de tag')], + static::TAGS => [Class_TagNotice::class, $this->_('suppression des codifications de tag')], static::INTEGRATION => [Class_Cosmogramme_Integration::class, $this->_('suppression des intégrations')], static::ANALYSE => [Class_IntAnalyse::class, $this->_('suppression des analyses d\'intégrations')], static::LOAN => [Class_Pret::class, $this->_('suppression des prêts')], diff --git a/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php b/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php index 566ee22c64daed295ff1c5a293f9ac6db242e65a..ed1e2fe3dfdf40b095dbbc3bc8e52fa315186f8b 100644 --- a/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php +++ b/library/Class/Cosmogramme/Integration/PhasePrepareIntegrations.php @@ -200,7 +200,7 @@ class Class_Cosmogramme_Integration_PhasePrepareIntegrations Class_Notice::basicDeleteAllFromSigb(); Class_Exemplaire::basicDeleteAllWithoutRecord(); - Class_CodifTags::basicDeleteBy([]); + Class_TagNotice::basicDeleteBy([]); Class_Notice_SerialArticles::basicDeleteBy([]); Class_NoticeSuccincte::basicDeleteBy([]); diff --git a/library/Class/CriteresRecherche.php b/library/Class/CriteresRecherche.php index 842c954e571bd539dccd4439912ff8df683278fc..50e9d440a6622a60a38e18d7d46b41c4d0503dd7 100644 --- a/library/Class/CriteresRecherche.php +++ b/library/Class/CriteresRecherche.php @@ -191,7 +191,7 @@ class Class_CriteresRecherche extends Class_CriteresRecherche_Abstract { $this->getSection()), $this->_selectionToArray(Class_CodifAnnexe::CODE_FACETTE, $this->getAnnexe()), - $this->_selectionToArray(Class_CodifTypeDoc::CODE_FACETTE, + $this->_selectionToArray(Class_TypeDoc::CODE_FACETTE, $this->getTypeDoc())))); } @@ -332,8 +332,8 @@ class Class_CriteresRecherche extends Class_CriteresRecherche_Abstract { protected function _getProfilFilters() : array { return [ - Class_CodifTypeDoc::CODE_FACETTE - => $this->_selectionToArray(Class_CodifTypeDoc::CODE_FACETTE, + Class_TypeDoc::CODE_FACETTE + => $this->_selectionToArray(Class_TypeDoc::CODE_FACETTE, $this->_profil->getSelTypeDoc()), Class_CodifAnnexe::CODE_FACETTE diff --git a/library/Class/CriteresRecherche/AxeParamBlock.php b/library/Class/CriteresRecherche/AxeParamBlock.php index 06a5fc4e2cb3c6482a42e3bf2c17eb5920fd814e..420b512f6fd4aa2cb8d21cc88588c572bcd71bd5 100644 --- a/library/Class/CriteresRecherche/AxeParamBlock.php +++ b/library/Class/CriteresRecherche/AxeParamBlock.php @@ -165,24 +165,27 @@ class Class_CriteresRecherche_AxeParamBlock Storm_Query_Criteria $criteria): self { $match = (new Storm_Query_MatchBoolean($field)); + $or_matchs = new Storm_Collection; foreach ($values as $value) { - $or_terms = new Storm_Collection; - $this->_terms - ->analyse($value); + $group_terms = new Storm_Collection; + $this->_terms->analyse($value); + $pertinence = $this->_pertinence || 1 === $this->_terms->wordsCount(); - $callback = ($this->_pertinence || 1 === $this->_terms->wordsCount()) - ? fn($variants) => $or_terms->addAll($variants) - : fn($variants) => $or_terms->add(Storm_Query_Clause_MatchTerms::and($variants)); + $callback = $pertinence + ? fn($variants) => $group_terms->addAll($variants) + : fn($variants) => $group_terms->add(Storm_Query_Terms::and($variants)); $this->_terms ->withVariantsDo($callback) - ->withExactWordsDo(fn($words) => $or_terms - ->add(Storm_Query_Clause_MatchTerms::orExact($words))); + ->withExactWordsDo(fn($words) => $group_terms->add(Storm_Query_Terms::andExact($words))); - $match->against_or($or_terms->getArrayCopy()); + $pertinence + ? $or_matchs->addAll($group_terms->getArrayCopy()) + : $or_matchs->add(Storm_Query_Terms::and($group_terms->getArrayCopy())); } + $match->against_or($or_matchs->getArrayCopy()); $this->_applyMatchTo($match, $criteria); return $this; diff --git a/library/Class/CriteresRecherche/CatalogueParams.php b/library/Class/CriteresRecherche/CatalogueParams.php index 66c4312c027d61d8cd15ce770997f3716e882e23..fe04705f447714664d95cb4f8bb86e5d152cf5d7 100644 --- a/library/Class/CriteresRecherche/CatalogueParams.php +++ b/library/Class/CriteresRecherche/CatalogueParams.php @@ -43,7 +43,7 @@ class Class_CriteresRecherche_CatalogueParams 'dewey' => Class_CodifDewey::class, 'pcdm4' => Class_CodifPcdm4::class, 'interet' => Class_CodifCentreInteret::class, - 'tags' => Class_CodifTags::class, + 'tags' => Class_TagNotice::class, 'bibliotheque' => Class_Bib::class, 'section' => Class_CodifSection::class, 'annexe' => Class_CodifAnnexe::class, diff --git a/library/Class/CriteresRecherche/Params.php b/library/Class/CriteresRecherche/Params.php index 7b33379f11aea09ae3fe12082a4b343511685bd8..85a409434e71ce37133ddeca578fd36c3c494600 100644 --- a/library/Class/CriteresRecherche/Params.php +++ b/library/Class/CriteresRecherche/Params.php @@ -52,7 +52,7 @@ class Class_CriteresRecherche_Params { 'dewey' => Class_CodifDewey::class, 'pcdm4' => Class_CodifPcdm4::class, 'interest' => Class_CodifCentreInteret::class, - 'tag' => Class_CodifTags::class, + 'tag' => Class_TagNotice::class, 'location' => Class_CodifEmplacement::class ]; } diff --git a/library/Class/Facet.php b/library/Class/Facet.php index 1d88e00f24d60ab31db64a4e3c02f5d8d9ab0f9d..bfbb3da914b17fddee679ec5757cc1e5c4a16534 100644 --- a/library/Class/Facet.php +++ b/library/Class/Facet.php @@ -173,7 +173,7 @@ class Class_Facet { public function isDocTypeFacet() : bool { - return $this->isGroupCode(Class_CodifTypeDoc::CODE_FACETTE); + return $this->isGroupCode(Class_TypeDoc::CODE_FACETTE); } diff --git a/library/Class/FacetsField.php b/library/Class/FacetsField.php new file mode 100644 index 0000000000000000000000000000000000000000..43dbcc73c2e8db4c5d8b97ecae7135e2a041c8f0 --- /dev/null +++ b/library/Class/FacetsField.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright (c) 2012-2024, 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 + */ + + +class Class_FacetsField +{ + + protected string $_label; + protected string $_code; + protected int $_count; + + public function __construct(string $label) + { + $this->_label = $label; + $this->_code = ''; + $this->_count = 0; + } + + + public static function code(string $code): string + { + return explode(Class_Codification::SEPARATOR_FACET, $code)[0] ?? ''; + } + + + public function getLabel(): string + { + return $this->_label; + } + + + public function getCode(): string + { + return $this->_code; + } + + + public function getCount(): string + { + return $this->_count; + } + + + public function addCodeAndCount(string $code, int $count): self + { + $this->_code .= ($this->_code ? Class_Codification::SEPARATOR_FACET : '') . $code; + $this->_count += $count; + + return $this; + } +} diff --git a/library/Class/Matiere.php b/library/Class/Matiere.php index ed24834bc7d1fad5d3fd845a785088189f4e10b3..d653855dc3c0d72e0093036e526a04c550dabacf 100644 --- a/library/Class/Matiere.php +++ b/library/Class/Matiere.php @@ -51,31 +51,16 @@ class Class_MatiereLoader extends Storm_Model_Loader { -class Class_Matiere extends Storm_Model_Abstract { +class Class_Matiere extends Storm_Model_Abstract +{ protected $_table_name = 'codif_matiere'; protected $_table_primary = 'id_matiere'; protected $_loader_class = 'Class_MatiereLoader'; protected $_default_attribute_values = ['libelle' => '']; - public function getSousVedettes() { - $vedette = $this->getLibelle(); - $children = $this->getLoader()->query() - ->start('libelle', $vedette . ' : ') - ->fetchAll(); - - if (0 == count($children)) - return ''; - - $sous_vedette = ''; - foreach($children as $child) - $sous_vedette.= $child->getId() . ' '; - - return $sous_vedette; - } - - - public function beforeSave() { + public function beforeSave() + { if ($this->isNew()) $this->setDateCreation(date('Y-m-d')); } diff --git a/library/Class/Moderer.php b/library/Class/Moderer.php index 3a939c238d33c173a43a5502aa453cc4648e12c4..8b90c06dd851203e76588dbda0e617b2776b0d24 100644 --- a/library/Class/Moderer.php +++ b/library/Class/Moderer.php @@ -35,7 +35,8 @@ class Class_Moderer { public function getAllTagsAModerer() { $tags = []; - foreach (Class_CodifTags::findAllBy(['where' => 'a_moderer > \'\'']) as $tag) + + foreach (Class_TagNotice::query()->gt('a_moderer', '')->fetchAll() as $tag) $this->_getTagToValidate($tag, $tags); return $tags; @@ -43,7 +44,7 @@ class Class_Moderer { protected function _getTagToValidate($tag, &$tags) { - foreach (explode(';', $tag->getAModerer()) as $id) + foreach (explode(Class_TagNotice::SEPARATOR, $tag->getAModerer()) as $id) $this->_getTagToValidateForRecord($id, $tag, $tags); } @@ -105,4 +106,4 @@ class Class_Moderer { return $this->_stats = $stats; } -} \ No newline at end of file +} diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index c80c2e02283a9ab9d385b6c94e881e6836f6c979..94a0335e28d4074e6b6942fe65b7e8b5b868857a 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -186,14 +186,7 @@ class Class_MoteurRecherche { if ($search_settings->getStateError()) return; - $domain_criteria = new Storm_Query_Criteria; - $clauses = new Class_MoteurRecherche_Clauses($domain_criteria); - $search_settings->acceptVisitor($clauses); - - $clauses->composeForSubCriteria(); - - if ($domain_criteria->hasClauses()) - $this->_query->wrapWithAnd($domain_criteria); + $search_settings->acceptVisitor($this->_clauses); } @@ -257,7 +250,8 @@ class Class_MoteurRecherche { } - public function compose(bool $force_type = false) : self { + public function compose(bool $force_type = false): self + { $this->_clauses->compose($force_type); return $this; diff --git a/library/Class/MoteurRecherche/Clauses.php b/library/Class/MoteurRecherche/Clauses.php index 6cff90880ed16a2c54f10da1ca921eda3d4f0f9a..6eadb52e7cfacfac0c65513b247695390c1c0df9 100644 --- a/library/Class/MoteurRecherche/Clauses.php +++ b/library/Class/MoteurRecherche/Clauses.php @@ -26,20 +26,18 @@ class Class_MoteurRecherche_Clauses { protected Storm_Query_CriteriaInterface $_criteria; protected Class_MoteurRecherche_Terms $_terms; protected ?Class_MoteurRecherche_AdvancedBlock $_advanced_blocks = null; - protected ?Storm_Query_MatchBoolean $_match_axes = null; - protected ?Storm_Query_MatchBoolean $_match_in_file = null; - protected ?Storm_Query_MatchBoolean $_or_multifacets = null; + protected Class_MoteurRecherche_MatchAxes $_match_axes; protected array $_rubrics = []; - protected array $_multi_facets = []; protected int $_record_type = Class_Notice::TYPE_BIBLIOGRAPHIC; /** @var array<Storm_Query_Criteria> */ protected array $_axes_criteria = []; - - public function __construct(Storm_Query_CriteriaInterface $criteria) { + public function __construct(Storm_Query_CriteriaInterface $criteria) + { $this->_criteria = $criteria; $this->_terms = new Class_MoteurRecherche_Terms; + $this->_match_axes = new Class_MoteurRecherche_MatchAxes; } @@ -55,17 +53,9 @@ class Class_MoteurRecherche_Clauses { } - public function composeForSubCriteria() : self { - foreach ($this->_multi_facets as $facets) - $this->_matchAllAxes()->against_and(array_unique($facets)); - - if ($this->_match_axes && $this->_match_in_file) - $this->_criteria->or((new Storm_Query_Criteria) - ->match($this->_match_axes) - ->match($this->_match_in_file)); - - if ($this->_match_axes && ! $this->_match_in_file) - $this->_criteria->match($this->_match_axes); + public function composeForSubCriteria(): self + { + $this->_match_axes->compose($this->_criteria); if ($this->_advanced_blocks) $this->_advanced_blocks->consumeAll(); @@ -73,10 +63,6 @@ class Class_MoteurRecherche_Clauses { foreach ($this->_axes_criteria as $criteria) $this->_criteria->append($criteria); - if ($this->_or_multifacets) - $this->_criteria->wrapWithOr((new Storm_Query_Criteria) - ->match($this->_or_multifacets)); - return $this; } @@ -106,7 +92,8 @@ class Class_MoteurRecherche_Clauses { public function visitExpression(string $expression, bool $pertinence = false, string $tri = '', - bool $in_files = false) : void { + bool $in_files = false): void + { // Analyse de l'expression $expression = trim($expression); if ('*' === $expression) @@ -116,18 +103,13 @@ class Class_MoteurRecherche_Clauses { if ($this->_handleAsIsbn($expression)) return; - $this->_terms->analyse($expression); - - $match = $this->_matchAllAxes(); $this->_terms - ->withExactWordsDo(fn($words) => $match->exact_and($words)) - ->withVariantsDo(fn($variants) => ($pertinence - ? $match->against_or($variants) - : $match->against_and($variants))); + ->analyse($expression) + ->withExactWordsDo(fn($words) => $this->_match_axes->addExactWords($words)) + ->withVariantsDo(fn($variants) => $this->_match_axes->addVariants($variants, $pertinence)); if ($in_files) - $this->_match_in_file = (new Storm_Query_MatchBoolean('file_content')) - ->against_or($expression); + $this->_match_axes->addFileContent($expression); } @@ -158,7 +140,7 @@ class Class_MoteurRecherche_Clauses { return; if ('guidee' !== $indice) - $this->_matchAllAxes()->against_and(Class_Notice_Facettes::PREFIX . $indice . '*'); + $this->_match_axes->addAndFacet(Class_Notice_Facettes::PREFIX . $indice . '*'); } @@ -186,19 +168,18 @@ class Class_MoteurRecherche_Clauses { public function visitFacette(string $facette) : void { - $this->_matchAllAxes()->against_and(Class_Notice_Facettes::PREFIX . $facette); + $this->_match_axes->addAndFacet(Class_Notice_Facettes::PREFIX . $facette); } - public function visitMultiFacet(string $multi_facet) : void { + public function visitMultiFacet(string $multi_facet): void + { if ( ! $multi_facet) return; $facet = Class_Facet::find($multi_facet); - if ($facet && ($code = $facet->getCodeRubrique())) { - $this->_multi_facets [$code] ??= []; - $this->_multi_facets [$code] [] = Class_Notice_Facettes::PREFIX . $multi_facet; - } + if ($facet && ($code = $facet->getCodeRubrique())) + $this->_match_axes->addMultiFacet($code, Class_Notice_Facettes::PREFIX . $multi_facet); } @@ -266,7 +247,7 @@ class Class_MoteurRecherche_Clauses { return; foreach (array_keys(Class_TypeDoc::getDigitalDocTypes()) as $type_doc) - $this->visitMultiFacet(Class_CodifTypeDoc::CODE_FACETTE . $type_doc); + $this->visitMultiFacet(Class_TypeDoc::CODE_FACETTE . $type_doc); } @@ -346,8 +327,7 @@ class Class_MoteurRecherche_Clauses { if ( ! $domain_id || ! ($facet = Class_Catalogue::find($domain_id)->getFacetCode())) return; - $this->_or_multifacets = (new Storm_Query_MatchBoolean(Class_MoteurRecherche::RECORD_WORDS)) - ->against_or(Class_Notice_Facettes::PREFIX . $facet); + $this->_match_axes->addOrDomain(Class_Notice_Facettes::PREFIX . $facet); } @@ -359,14 +339,16 @@ class Class_MoteurRecherche_Clauses { } - public function visitAuthority(Class_CriteresRecherche_AuthorityParam $authority) : void { - if ($facets = $authority->facets()) - $this->_queryFacet($facets); + public function visitAuthority(Class_CriteresRecherche_AuthorityParam $authority): void + { + foreach ($authority->facets() as $facet) + $this->visitMultiFacet($facet); } public function visitFiltre(array $facets) : void { - $this->_queryFacet($facets); + foreach ($facets as $facet) + $this->visitMultiFacet($facet); } @@ -393,18 +375,4 @@ class Class_MoteurRecherche_Clauses { return $this; } - - - protected function _queryFacet(array $facets) : self { - $this->_matchAllAxes()->against_and(array_map(fn($facet) => Class_Notice_Facettes::PREFIX . $facet, - $facets)); - - return $this; - } - - - protected function _matchAllAxes() : Storm_Query_MatchBoolean { - return $this->_match_axes - ??= new Storm_Query_MatchBoolean(Class_MoteurRecherche::RECORD_WORDS); - } } diff --git a/library/Class/MoteurRecherche/MatchAxes.php b/library/Class/MoteurRecherche/MatchAxes.php new file mode 100644 index 0000000000000000000000000000000000000000..ef12af8a7324396d6b4990616c2ed1ab4a3efa1a --- /dev/null +++ b/library/Class/MoteurRecherche/MatchAxes.php @@ -0,0 +1,189 @@ +<?php +/** + * Copyright (c) 2012-2024, 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 + */ + + +class Class_MoteurRecherche_MatchAxes +{ + + protected array $_and_facets = []; + protected array $_exact_words = []; + protected string $_or_domain = ''; + protected Class_MoteurRecherche_MatchAxesVariantsWords $_variants_words; + protected ?Storm_Collection $_multi_facets = null; + protected ?Storm_Query_MatchBoolean $_match_axes = null; + protected ?Storm_Query_MatchBoolean $_match_in_file = null; + + public function __construct() + { + $this->_variants_words = new Class_MoteurRecherche_MatchAxesVariantsWords; + } + + + public function compose(Storm_Query_CriteriaInterface $criteria): self + { + foreach ($this->_exact_words as $exact_words) + $this->_matchAllAxes()->exact_and($exact_words); + + foreach ($this->_variants_words->andVariants() as $and_variants) + $this->_matchAllAxes()->against_and($and_variants); + + foreach ($this->_variants_words->orVariants() as $or_variants) + $this->_matchAllAxes()->against_or($or_variants); + + $this->_composeAndFacets(); + $this->_composeOrFacets(); + + if ($this->_match_axes && $this->_match_in_file) + $criteria->or((new Storm_Query_Criteria) + ->match($this->_match_axes) + ->match($this->_match_in_file)); + + if ($this->_match_axes && ! $this->_match_in_file) + $criteria->match($this->_match_axes); + + return $this; + } + + + protected function _composeAndFacets(): self + { + if ($this->_or_domain) + return $this; + + foreach (array_unique(array_filter($this->_and_facets)) as $facet) + $this->_matchAllAxes()->against_and($facet); + + if ( ! $this->_multi_facets) + return $this; + + $this->_multi_facets->eachDo(function($multi) + { + if ($multi_facets = $multi->compose()) + $this->_matchAllAxes()->against_and($multi_facets); + }); + + return $this; + } + + + protected function _composeOrFacets(): self + { + if ( ! $this->_or_domain) + return $this; + + $match_terms = []; + foreach (array_unique(array_filter($this->_and_facets)) as $facet) + $match_terms [] = Storm_Query_Terms::and([$facet]); + + if ($this->_multi_facets) + $this->_multi_facets->eachDo(function($multi) use (&$match_terms) + { + if ($multi_facets = $multi->compose()) + $match_terms [] = Storm_Query_Terms::and($multi_facets); + }); + + if ( ! $match_terms) + { + $this->_matchAllAxes()->against_or($this->_or_domain); + + return $this; + } + + $this->_matchAllAxes() + ->against_and(Storm_Query_Terms::or([Storm_Query_Terms::and($match_terms), + $this->_or_domain])); + + return $this; + } + + + public function addAndFacet(string $facet): self + { + $this->_and_facets [] = $facet; + + return $this; + } + + + public function addOrDomain(string $facet): self + { + $this->_or_domain = $facet; + + return $this; + } + + + public function addMultiFacet(string $code, string $facet): self + { + $multi_facet = $this->_multiFacets() + ->detect(fn($multi) => $multi->isSameCode($code)); + + if ( ! $multi_facet) + { + $multi_facet = new Class_MoteurRecherche_MatchAxesMultiFacets($code); + $this->_multiFacets()->add($multi_facet); + } + + $multi_facet->addMultiFacet($facet); + + return $this; + } + + + public function addFileContent(string $expression): self + { + if ($expression) + $this->_match_in_file = (new Storm_Query_MatchBoolean('file_content')) + ->against_or($expression); + + return $this; + } + + + public function addExactWords(string $words): self + { + if ($words) + $this->_exact_words [] = $words; + + return $this; + } + + + public function addVariants(array $variants, bool $pertinence): self + { + $this->_variants_words->addVariants($variants, $pertinence); + + return $this; + } + + + protected function _multiFacets(): Storm_Collection + { + return $this->_multi_facets ??= new Storm_Collection; + } + + + protected function _matchAllAxes(): Storm_Query_MatchBoolean + { + return $this->_match_axes + ??= new Storm_Query_MatchBoolean(Class_MoteurRecherche::RECORD_WORDS); + } +} diff --git a/tests/library/Class/MatiereTest.php b/library/Class/MoteurRecherche/MatchAxesMultiFacets.php similarity index 53% rename from tests/library/Class/MatiereTest.php rename to library/Class/MoteurRecherche/MatchAxesMultiFacets.php index 3477285c71e70d62987dcc1f17f64ca3e3584cdf..f1cdf6ebf4707ca71f4f18bb2e358ed84add0cf6 100644 --- a/tests/library/Class/MatiereTest.php +++ b/library/Class/MoteurRecherche/MatchAxesMultiFacets.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012-2024, 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 @@ -19,20 +19,37 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class MatiereTest extends ModelTestCase { - - /** @test */ - function sqlQueriesShouldBeEscaped() { - $matiere = $this->fixture(Class_Matiere::class, - ['id' => 4, - 'libelle' => 'L\'art du 20ème']); - $this->fixture(Class_Matiere::class, - ['id' => 12, - 'libelle' => 'L\'art du 20ème : peinture']); - $this->fixture(Class_Matiere::class, - ['id' => 24, - 'libelle' => 'L\'art du 20ème : musique']); - - $this->assertEquals('12 24 ', $matiere->getSousVedettes()); + +class Class_MoteurRecherche_MatchAxesMultiFacets +{ + + protected string $_facet_code = ''; + protected array $_multi_facets = []; + + public function __construct(string $code) + { + $this->_facet_code = $code; + } + + + public function compose(): array + { + return $this->_facet_code + ? array_unique(array_filter($this->_multi_facets)) + : []; + } + + + public function isSameCode(string $facet_code): bool + { + return $facet_code === $this->_facet_code; + } + + + public function addMultiFacet(string $facet): self + { + $this->_multi_facets [] = $facet; + + return $this; } } diff --git a/library/Class/MoteurRecherche/MatchAxesVariantsWords.php b/library/Class/MoteurRecherche/MatchAxesVariantsWords.php new file mode 100644 index 0000000000000000000000000000000000000000..30f56e7dc7e70a4332205130ef5dacd9c121a81e --- /dev/null +++ b/library/Class/MoteurRecherche/MatchAxesVariantsWords.php @@ -0,0 +1,66 @@ +<?php +/** + * Copyright (c) 2012-2024, 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 + */ + + +class Class_MoteurRecherche_MatchAxesVariantsWords +{ + + protected array $_and_variants = []; + protected array $_or_variants = []; + + public function andVariants(): array + { + return $this->_and_variants; + } + + + public function orVariants(): array + { + return $this->_or_variants; + } + + + public function addVariants(array $variants, bool $pertinence): self + { + if ( ! $variants) + return $this; + + return $pertinence + ? $this->_addOrVariants($variants) + : $this->_addAndVariants($variants); + } + + + protected function _addAndVariants(array $variants): self + { + $this->_and_variants [] = $variants; + + return $this; + } + + + protected function _addOrVariants(array $variants): self + { + $this->_or_variants [] = $variants; + + return $this; + } +} diff --git a/library/Class/NatureDoc.php b/library/Class/NatureDoc.php index 51379e041fd27d32ef6dfb7e2b53cf7a2ce237eb..ba05b9ca7bddb62c159a37196a0fcadb25592840 100644 --- a/library/Class/NatureDoc.php +++ b/library/Class/NatureDoc.php @@ -75,10 +75,9 @@ class NatureDocLoader extends Class_CosmoVar_ModelLoader { } - - public function find($id) { - $all = $this->findAll(); - return isset($all[$id]) ? $all[$id] : null; + public function find($id): ?Storm_Model_Abstract + { + return $this->findAll()[$id] ?? null; } diff --git a/library/Class/Notice/DataMap/UnimarcBiblio.php b/library/Class/Notice/DataMap/UnimarcBiblio.php index 2b49792e4c702269e8a39ce58f352503f30aa164..1a860ac71ba1e5edae6b97ae424c7b295d672482 100644 --- a/library/Class/Notice/DataMap/UnimarcBiblio.php +++ b/library/Class/Notice/DataMap/UnimarcBiblio.php @@ -98,7 +98,7 @@ class Class_Notice_DataMap_UnimarcBiblio extends Class_Notice_DataMap_Abstract { protected function _isReboundField($field) { return in_array($field, - [Class_CodifTags::CODE_FACETTE, + [Class_TagNotice::CODE_FACETTE, Class_CodifDewey::CODE_FACETTE, Class_CodifPcdm4::CODE_FACETTE, Class_CodifMatiere::CODE_FACETTE, diff --git a/library/Class/Notice/Facettes.php b/library/Class/Notice/Facettes.php index 5944e8a90be3f976a78b5d9469b54375f332843f..3d58373a7d021be4685e8b752075298c7ed681c2 100644 --- a/library/Class/Notice/Facettes.php +++ b/library/Class/Notice/Facettes.php @@ -46,7 +46,7 @@ class Class_Notice_Facettes { $facets = array_map(function($facet) { return $facet->getCle(); }, $facets); - $facets [] = Class_CodifTypeDoc::CODE_FACETTE . $this->_record->getTypeDoc(); + $facets [] = Class_TypeDoc::CODE_FACETTE . $this->_record->getTypeDoc(); $is_novelty = false; $date_nouveaute = ''; diff --git a/library/Class/TagNotice.php b/library/Class/TagNotice.php index 60f8c9add75f11b1f1838ce514c9e6dbe7cad1ad..bacb38e305d479cebc86a6ffac13281fb8624102 100644 --- a/library/Class/TagNotice.php +++ b/library/Class/TagNotice.php @@ -19,7 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class Class_TagNoticeLoader extends Storm_Model_Loader { +class Class_TagNoticeLoader extends Storm_Model_Loader +{ + use Trait_FacetableLoader; public function multiForRecord($labels, $record_id) { foreach($labels as $label) @@ -60,16 +62,26 @@ class Class_TagNoticeLoader extends Storm_Model_Loader { public function getListeSuggestion($value, $mode, $limit) { return (new Class_CodifSuggest(Class_TagNotice::getLoader()))->suggest($value, $mode, $limit); } + + + public function findForRecord(int $id): array + { + return $this->query() + ->match((new Storm_Query_MatchBoolean('notices')) + ->against_and($id)) + ->fetchAll(); + } } -class Class_TagNotice extends Storm_Model_Abstract { +class Class_TagNotice extends Storm_Model_Abstract +{ use Trait_Facetable; const CODE_FACETTE = 'Z'; - const SEPARATOR = ';'; + const SEPARATOR = ' '; protected $_table_name = 'codif_tags'; protected $_table_primary = 'id_tag'; @@ -77,7 +89,6 @@ class Class_TagNotice extends Storm_Model_Abstract { protected $_default_attribute_values = ['notices' => '', 'a_moderer' => '']; - public function linkTo($record) { $this ->addRecord($record) @@ -168,7 +179,7 @@ class Class_TagNotice extends Storm_Model_Abstract { public function setRecordsIntoField($records, $field) { $value = $records - ? static::SEPARATOR . implode(static::SEPARATOR, $records) . static::SEPARATOR + ? trim(implode(static::SEPARATOR, $records)) : ''; $this->callSetterByAttributeName($field, $value); diff --git a/library/Class/TypeDoc.php b/library/Class/TypeDoc.php index df3cf8b0146ff609be5abbb74f6df4393dcf211b..d188a8ec367e4e8f0375eeb915434c37411b61be 100644 --- a/library/Class/TypeDoc.php +++ b/library/Class/TypeDoc.php @@ -19,14 +19,24 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -class TypeDocLoader extends Class_CosmoVar_ModelLoader { - use Trait_Translator; + +class TypeDocLoader extends Class_CosmoVar_ModelLoader +{ + use Trait_Translator, Trait_FacetableLoader; protected $_cosmo_var_name = 'types_docs', $_all_instances, $_used_ids_cache; + public function facetLabelFor(string $id): string + { + return ($type_doc = $this->find($id)) + ? $type_doc->getLabel() + : ''; + } + + public function newInstanceWithId($id, $attributes = null) { $instance = $this->newInstance($attributes) ->setId((string)$id); @@ -36,11 +46,9 @@ class TypeDocLoader extends Class_CosmoVar_ModelLoader { } - public function find($id) { - $instances = $this->findAll(); - if (array_key_exists($id, $instances)) - return $instances[$id]; - return null; + public function find($id): ?Storm_Model_Abstract + { + return $this->findAll()[$id] ?? null; } @@ -219,18 +227,18 @@ class TypeDocLoader extends Class_CosmoVar_ModelLoader { } - public function getMultiOptionsFacets() { + public function getMultiOptionsFacets(): array + { $multi_options = $this->getMultiOptions(); - $multi_options_facets=[]; + $multi_options_facets = []; - foreach ($multi_options as $id => $label) { - if (!$doctype = Class_TypeDoc::find($id)) - continue; - $multi_options_facets[$doctype->getFacetCode()] = $doctype->getLabel(); - } - if (!$multi_options_facets) - return; + foreach ($multi_options as $id => $label) + if ($doctype = Class_TypeDoc::find($id)) + $multi_options_facets [$doctype->getFacetCode()] = $doctype->getLabel(); + + if ( ! $multi_options_facets) + return []; asort($multi_options_facets, SORT_NATURAL | SORT_FLAG_CASE); array_unshift($multi_options_facets, $this->_('tous')); @@ -326,18 +334,18 @@ class TypeDocLoader extends Class_CosmoVar_ModelLoader { -class Class_TypeDoc extends Storm_Model_Abstract { - use Trait_Facetable, Trait_Translator; - - const - CODE_FACETTE = 'T', - DIGITAL_RESOURCE_THRESHOLD = 100; +class Class_TypeDoc extends Storm_Model_Abstract +{ + use Trait_Translator, Trait_Facetable; protected $_loader_class = TypeDocLoader::class; protected $_belongs_to = ['codif_type_doc' => ['model' => 'Class_CodifTypeDoc', 'referenced_in' => 'id' ]]; + const + CODE_FACETTE = 'T', + DIGITAL_RESOURCE_THRESHOLD = 100, UNKNOWN = 0, LIVRE = 1, PERIODIQUE = 2, @@ -367,7 +375,6 @@ class Class_TypeDoc extends Storm_Model_Abstract { SOUNDCLOUD = 117, CITEDELAMUSIQUE = 119; - public static function getDefaultTypeDocs() { $instance = new Class_TypeDoc; return [self::LIVRE => $instance->_('Livres'), @@ -463,13 +470,6 @@ class Class_TypeDoc extends Storm_Model_Abstract { } - public static function facetLabelFor($id) { - return ($type_doc = static::find($id)) - ? $type_doc->getLabel() - : ''; - } - - public function getCodifTypeDoc() { if ($codif=parent::_get('codif_type_doc')) return $codif; diff --git a/library/Trait/Facetable.php b/library/Trait/Facetable.php index 2c284bc19ca88d670cca80df2ea248aab07e6a41..a1116fc74ede598d6961b2865e8919f90704d928 100644 --- a/library/Trait/Facetable.php +++ b/library/Trait/Facetable.php @@ -20,22 +20,17 @@ */ -trait Trait_Facetable { - /** @return string */ - public static function facetLabelFor($id) { - return ($model = static::find((int)$id)) - ? $model->getLibelle() - : ''; - } - +trait Trait_Facetable +{ - /** @return string */ - public function asFacet() { + public function asFacet(): string + { return static::CODE_FACETTE . $this->getId(); } - public function getFacetCode() { + public function getFacetCode(): string + { return $this->asFacet(); } -} \ No newline at end of file +} diff --git a/library/Class/CodifTags.php b/library/Trait/FacetableLoader.php similarity index 57% rename from library/Class/CodifTags.php rename to library/Trait/FacetableLoader.php index 661b122c7c5aeb8940f7bc4ef8f8fe309ad63a70..0a80f852cc9bf8c71cee3783026aa81bd8d433e5 100644 --- a/library/Class/CodifTags.php +++ b/library/Trait/FacetableLoader.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012-2024, 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 @@ -20,23 +20,31 @@ */ -class Class_CodifTagsLoader extends Storm_Model_Loader { - public function findForRecord($id) { - return Class_CodifTags::findAll('select * from codif_tags where MATCH(notices) AGAINST( "+;' . (int)$id . ';" IN BOOLEAN MODE)'); - } -} +trait Trait_FacetableLoader +{ + + public function facetLabelFor(string $id): string + { + $query = $this->query()->select('libelle'); + + $rows = $this->_criteriaOnQuery($query, $id) + ->beBasic() + ->fetchFirst(); + return $rows + ? ($rows['libelle'] ?? '') + : $this->_default($id); + } -class Class_CodifTags extends Storm_Model_Abstract { - use Trait_Facetable; + protected function _criteriaOnQuery(Storm_Query $query, string $id): Storm_Query + { + return $query->eq($this->getIdField(), $id); + } - const CODE_FACETTE = 'Z'; - const SEPARATOR = ';'; - protected - $_table_name = 'codif_tags', - $_table_primary = 'id_tag', - $_loader_class = 'Class_CodifTagsLoader', - $_default_attribute_values = ['a_moderer' => '']; -} \ No newline at end of file + protected function _default(string $id): string + { + return ''; + } +} diff --git a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Codification.php b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Codification.php index dd2eafec5d481df12f970a022b270ea4a1c288c5..dde7487472ecc6329e2f54e8f75b5b612fc9f00a 100644 --- a/library/ZendAfi/Controller/Action/Helper/ListViewMode/Codification.php +++ b/library/ZendAfi/Controller/Action/Helper/ListViewMode/Codification.php @@ -80,7 +80,7 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Codification ->setLibelle($this->_('Sujets et matières')) ->setController('subject-browser'), - (new Class_CodifTags) + (new Class_TagNotice) ->setLibelle($this->_('Tags')) ->setController('tag-browser'), @@ -152,4 +152,4 @@ class ZendAfi_Controller_Action_Helper_ListViewMode_Codification return ['module' => 'admin', 'controller' => $model->getController()]; } -} \ No newline at end of file +} diff --git a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Tag.php b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Tag.php index c12043e2a2ff58e4c064000f9394e0103746e361..2367cdd846a1923aff1b97ad88b2ad5fd97c7fde 100644 --- a/library/ZendAfi/Controller/Plugin/ResourceDefinition/Tag.php +++ b/library/ZendAfi/Controller/Plugin/ResourceDefinition/Tag.php @@ -25,7 +25,7 @@ class ZendAfi_Controller_Plugin_ResourceDefinition_Tag public function getDefinitions() { return - ['model' => ['class' => 'Class_CodifTags', + ['model' => ['class' => 'Class_TagNotice', 'name' => 'tag', 'order' => 'libelle'], @@ -54,4 +54,4 @@ class ZendAfi_Controller_Plugin_ResourceDefinition_Tag 'anchorOptions' => ['target' => '_blank'] ]]; } -} \ No newline at end of file +} diff --git a/library/ZendAfi/View/Helper/Accueil/Tags.php b/library/ZendAfi/View/Helper/Accueil/Tags.php index db51c1777e442021a725b1301696a0e438743982..99d18bcbb9a98f2226d8441b3ac6430197f74cac 100644 --- a/library/ZendAfi/View/Helper/Accueil/Tags.php +++ b/library/ZendAfi/View/Helper/Accueil/Tags.php @@ -121,4 +121,4 @@ class ZendAfi_View_Helper_Accueil_Tags extends ZendAfi_View_Helper_Accueil_Base return $facettes; } -} \ No newline at end of file +} diff --git a/library/ZendAfi/View/Helper/Cosmo/DeleteItemsAllDashboard.php b/library/ZendAfi/View/Helper/Cosmo/DeleteItemsAllDashboard.php index e9ded6a3a6fa9045f6674531c0654958a224cdf0..69d274ff3f092fa688f37bb0ba55b0343248c76c 100644 --- a/library/ZendAfi/View/Helper/Cosmo/DeleteItemsAllDashboard.php +++ b/library/ZendAfi/View/Helper/Cosmo/DeleteItemsAllDashboard.php @@ -73,7 +73,7 @@ class ZendAfi_View_Helper_Cosmo_DeleteItemsAllDashboard $this->_('%d notices succinctes', Class_NoticeSuccincte::count()), $this->_('%d exemplaires', Class_Exemplaire::count()), $this->_('%d statistiques des notices', Class_StatsNotices::count()), - $this->_('%d codifications de tags', Class_CodifTags::count()), + $this->_('%d codifications de tags', Class_TagNotice::count()), $this->_('%d integrations', Class_Cosmogramme_Integration::count()), $this->_('%d analyses d\'intégrations', Class_IntAnalyse::count()), $this->_('%d prêts', Class_Pret::count()), diff --git a/library/ZendAfi/View/Helper/Facettes.php b/library/ZendAfi/View/Helper/Facettes.php index 9d8c04574ae68503ed48442cba13a8ffeee6c489..efee39216a88dd32b8d189ea54eb06a60a86d191 100644 --- a/library/ZendAfi/View/Helper/Facettes.php +++ b/library/ZendAfi/View/Helper/Facettes.php @@ -178,7 +178,8 @@ class ZendAfi_View_Helper_Facettes extends ZendAfi_View_Helper_BaseHelper { protected function _renderLi(array $url, string $code, int $count): string { - $label = Class_Codification::getInstance()->getLibelleFacette($code); + $label = Class_Codification::getInstance() + ->getLibelleFacette(Class_FacetsField::code($code)); $title = Class_Codification::getInstance()->getNomChamp($code); return $this diff --git a/library/ZendAfi/View/Helper/Search/RubricsNavigation.php b/library/ZendAfi/View/Helper/Search/RubricsNavigation.php index 8622d6b2362957f1508a86c3f67b48974ffc2dd3..a8a7dde311864569ace82c3d699466a6dfbd45c1 100644 --- a/library/ZendAfi/View/Helper/Search/RubricsNavigation.php +++ b/library/ZendAfi/View/Helper/Search/RubricsNavigation.php @@ -241,24 +241,28 @@ class ZendAfi_View_Helper_Search_RubricsNavigationItem { -class Class_MoteurRecherche_FakeRubric { +class Class_MoteurRecherche_FakeRubric +{ use Trait_Facetable; protected string $_facet_code; protected string $_label; - public function __construct(string $facet_code, string $label) { + public function __construct(string $facet_code, string $label) + { $this->_facet_code = $facet_code; $this->_label = $label; } - public function asFacet() : string { + public function asFacet(): string + { return $this->_facet_code; } - public function getLibelle() : string { + public function getLibelle(): string + { return $this->_label; } } diff --git a/library/ZendAfi/View/Helper/TagListeSuggestion.php b/library/ZendAfi/View/Helper/TagListeSuggestion.php index 27dfa0346e0aef6ec948fcba49b724721efb290b..57eb948a2e135df157d08a18efa84217f31da92f 100644 --- a/library/ZendAfi/View/Helper/TagListeSuggestion.php +++ b/library/ZendAfi/View/Helper/TagListeSuggestion.php @@ -209,7 +209,7 @@ class ZendAfi_View_Helper_TagListeSuggestion 'dewey' => [Class_CodifDewey::class, $dewey_pcdm4_options], 'pcdm4' => [Class_CodifPcdm4::class, $dewey_pcdm4_options], 'thesaurus' => [Class_CodifThesaurus::class], - 'tag' => [Class_CodifTags::class] + 'tag' => [Class_TagNotice::class] ]; return array_key_exists($type, $map) diff --git a/library/digital_resources/Numel/tests/NumelTest.php b/library/digital_resources/Numel/tests/NumelTest.php index 2b85293077469235b70cfde4984c59aa22a29996..8cf92dd0b066ee17e6910bdd3864636b7299b65b 100644 --- a/library/digital_resources/Numel/tests/NumelTest.php +++ b/library/digital_resources/Numel/tests/NumelTest.php @@ -152,6 +152,7 @@ class NumelDashboardActivatedTest extends NumelActivatedTestCase $this->assertSqlEquals(["SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'Digital resources' AND `codif_thesaurus`.`id_thesaurus` LIKE 'DRDR%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", "SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'Digital resources' AND `codif_thesaurus`.`id_thesaurus` LIKE 'DRDR0001%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", "SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'Digital resources' AND `codif_thesaurus`.`id_thesaurus` LIKE 'DRDR00010002%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", + "SELECT `codif_tags`.* FROM `codif_tags` WHERE (`codif_tags`.`a_moderer` > '')", "SELECT COUNT(*) AS `numberof` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_B3' IN BOOLEAN MODE) AND `notices`.`type` = 1)", "SELECT COUNT(*) AS `numberof` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_T0 +F_B3' IN BOOLEAN MODE) AND `notices`.`type` = 1)", "SELECT COUNT(*) AS `numberof` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_HDRDR000100020001 +F_YArchivesdeMelun +F_B3' IN BOOLEAN MODE) AND `notices`.`type` = 1)", diff --git a/library/storm b/library/storm index af9659565a744434c48c8f2ba37c335e93d444bf..ac866c58091897ebb4714b09df8ab9b39a8647c7 160000 --- a/library/storm +++ b/library/storm @@ -1 +1 @@ -Subproject commit af9659565a744434c48c8f2ba37c335e93d444bf +Subproject commit ac866c58091897ebb4714b09df8ab9b39a8647c7 diff --git a/library/templates/Chili/Library/ProfilePatcher.php b/library/templates/Chili/Library/ProfilePatcher.php index 53fedc697a7f14e294a58b0d8ec8dfc78be97a6b..051f1f7236ff0e8a0117bb6fb0a7e8875de6ccf3 100644 --- a/library/templates/Chili/Library/ProfilePatcher.php +++ b/library/templates/Chili/Library/ProfilePatcher.php @@ -679,4 +679,4 @@ class Chili_Library_ProfilePatcher extends Intonation_Library_ProfilePatcher { $this->_template->withNameSpace('show_content') => 0, $this->_template->withNameSpace('show_footer') => 0]; } -} \ No newline at end of file +} diff --git a/library/templates/Intonation/Library/View/Wrapper/Record.php b/library/templates/Intonation/Library/View/Wrapper/Record.php index 8dc71a4ac16b55844992551137a2a271db2cff97..18e7dc14dc8298a5db6b81980ee8943c6ab519e0 100644 --- a/library/templates/Intonation/Library/View/Wrapper/Record.php +++ b/library/templates/Intonation/Library/View/Wrapper/Record.php @@ -218,7 +218,7 @@ class Intonation_Library_View_Wrapper_Record ->setClass('record_doctype') ->setUrl($this->_view->url(['controller' => 'recherche', 'action' => 'simple', - 'facette' => Class_CodifTypeDoc::CODE_FACETTE. $this->_model->getTypeDoc(), + 'facette' => Class_TypeDoc::CODE_FACETTE. $this->_model->getTypeDoc(), 'page' => null])) ->setImage(($this->getIco($this->_model->getTypeDocLabel(), 'doc_types'))) ->setText($this->decorateLabel($this->_model->getTypeDocLabel())) @@ -467,7 +467,7 @@ class Intonation_Library_View_Wrapper_Record protected function _getFacets() { $instance_facets = $this->_model->getFacettes(); - $codes = [Class_CodifTags::CODE_FACETTE, + $codes = [Class_TagNotice::CODE_FACETTE, Class_CodifMatiere::CODE_FACETTE, Class_CodifGenre::CODE_FACETTE, Class_CodifCentreInteret::CODE_FACETTE]; diff --git a/library/templates/Intonation/View/Search/Facets.php b/library/templates/Intonation/View/Search/Facets.php index d272976a065853100c676a4049071e2a4777ac05..35dc700d710eea649bdb661993b1a329ad839d0d 100644 --- a/library/templates/Intonation/View/Search/Facets.php +++ b/library/templates/Intonation/View/Search/Facets.php @@ -214,7 +214,7 @@ class Intonation_View_Search_Facets extends ZendAfi_View_Helper_Facettes { $label = Class_Codification::getInstance()->getLibelleFacette($code); $field = $facet_fields->detect(fn($facet) => $label === $facet->getLabel()); if (!$field) { - $field = new Search_Facets_Field($label); + $field = new Class_FacetsField($label); $facet_fields->add($field); } @@ -223,42 +223,3 @@ class Intonation_View_Search_Facets extends ZendAfi_View_Helper_Facettes { return $this; } } - - - - -class Search_Facets_Field { - - protected string $_label; - protected string $_code; - protected int $_count; - - public function __construct(string $label) { - $this->_label = $label; - $this->_code = ''; - $this->_count = 0; - } - - - public function getLabel() : string { - return $this->_label; - } - - - public function getCode() : string { - return $this->_code; - } - - - public function getCount() : string { - return $this->_count; - } - - - public function addCodeAndCount(string $code, int $count) : self { - $this->_code .= ($this->_code ? '+' : '') . $code; - $this->_count += $count; - - return $this; - } -} diff --git a/tests/application/modules/admin/controllers/ModoControllerTest.php b/tests/application/modules/admin/controllers/ModoControllerTest.php index 743cd03c38397619a3895f2c7b92d09da5a8eec8..4f2da2354a9106c2787d32fda4b4981718366c6f 100644 --- a/tests/application/modules/admin/controllers/ModoControllerTest.php +++ b/tests/application/modules/admin/controllers/ModoControllerTest.php @@ -21,7 +21,6 @@ abstract class ModoControllerIndexActionTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); @@ -29,97 +28,111 @@ abstract class ModoControllerIndexActionTestCase extends Admin_AbstractControlle Class_AdminVar::set('AVIS_MIN_SAISIE', 2); Class_AdminVar::set('AVIS_MAX_SAISIE', 2000); - $this->fixture('Class_Notice', ['id' => 1002, - 'titre_principal' => 'Para Ana']); - - $this->fixture('Class_Notice', ['id' => 1003, - 'titre_principal' => 'Maison de la Nuit (La)']); - - $this->fixture('Class_CodifTags', ['id' => 1, - 'a_moderer' => '1002', - 'libelle' => 'litteratures espagnol', - 'code_alpha' => 'LITTERATURES ESPAGNOL']); - - $this->fixture('Class_CodifTags', ['id' => 2, - 'a_moderer' => '1002;1003;8890', - 'libelle' => 'muerto', - 'code_alpha' => 'MUERTO']); - - $this->fixture('Class_Avis', ['id' => 1, - 'id_notice' => 1002, - 'statut' => 0]); - - $this->fixture(Class_AvisNotice::class, ['id' => 1, - 'id_notice' => 1002, - 'entete' => 'Mon avis', - 'note'=> 2, - 'id_user' => null, - 'avis' => 'Ce livre est vraiment bien !', - 'statut' => 0, - 'abon_ou_bib' => 1, - 'source_author' => null]); - - $this->fixture(Class_AvisNotice::class, ['id' => 223, - 'id_notice' => 1002, - 'entete' => 'Bulles', - 'note'=> 2, - 'id_user' => null, - 'flags' => 0, - 'avis' => ' Pour faire aimer la biere aux enfants!', - 'id_notice' => 1032, - 'statut' => 1, - 'abon_ou_bib' => 1, - 'source_author' => null]); - - $this->fixture('Class_Notice', ['id' => 1032, - 'titre_principal' => 'B comme bière : la bière expliquée aux (grands) enfants']); - - $this->fixture('Class_SuggestionAchat', ['id' => 92, - 'titre' => 'Kikolol', - 'auteur' => 'Moi', - 'isbn' => '', - 'description_url' => 'http://livre.com/1', - 'type_doc_id' => 1]); - - $this->fixture('Class_UsersNonValid', ['id_user' => 8, - 'id' => 8, - 'login' => 'moo', - 'password' => 'moo', - 'mail' => 'moo@moo.com',]); - - $this->fixture('Class_UsersNonValid', ['id_user' => 9, - 'id' => 9, - 'login' => 'Simon', - 'password' => 'LeHerisson', - 'mail' => 'simon-le-herisson@gmail.com',]); + $this->fixture(Class_Notice::class, + ['id' => 1002, + 'titre_principal' => 'Para Ana']); + + $this->fixture(Class_Notice::class, + ['id' => 1003, + 'titre_principal' => 'Maison de la Nuit (La)']); + + $this->fixture(Class_TagNotice::class, + ['id' => 1, + 'a_moderer' => '1002', + 'libelle' => 'litteratures espagnol', + 'code_alpha' => 'LITTERATURES ESPAGNOL']); + + $this->fixture(Class_TagNotice::class, + ['id' => 2, + 'a_moderer' => '1002 1003 8890', + 'libelle' => 'muerto', + 'code_alpha' => 'MUERTO']); + + $this->fixture(Class_Avis::class, + ['id' => 1, + 'id_notice' => 1002, + 'statut' => 0]); + + $this->fixture(Class_AvisNotice::class, + ['id' => 1, + 'id_notice' => 1002, + 'entete' => 'Mon avis', + 'note' => 2, + 'id_user' => null, + 'avis' => 'Ce livre est vraiment bien !', + 'statut' => 0, + 'abon_ou_bib' => 1, + 'source_author' => null]); + + $this->fixture(Class_AvisNotice::class, + ['id' => 223, + 'id_notice' => 1002, + 'entete' => 'Bulles', + 'note' => 2, + 'id_user' => null, + 'flags' => 0, + 'avis' => ' Pour faire aimer la biere aux enfants!', + 'id_notice' => 1032, + 'statut' => 1, + 'abon_ou_bib' => 1, + 'source_author' => null]); + + $this->fixture(Class_Notice::class, + ['id' => 1032, + 'titre_principal' => 'B comme bière : la bière expliquée aux (grands) enfants']); + + $this->fixture(Class_SuggestionAchat::class, + ['id' => 92, + 'titre' => 'Kikolol', + 'auteur' => 'Moi', + 'isbn' => '', + 'description_url' => 'http://livre.com/1', + 'type_doc_id' => 1]); + + $this->fixture(Class_UsersNonValid::class, + ['id_user' => 8, + 'id' => 8, + 'login' => 'moo', + 'password' => 'moo', + 'mail' => 'moo@moo.com',]); + + $this->fixture(Class_UsersNonValid::class, + ['id_user' => 9, + 'id' => 9, + 'login' => 'Simon', + 'password' => 'LeHerisson', + 'mail' => 'simon-le-herisson@gmail.com',]); $this->generateReviews(); } protected function generateReviews() { - for($i = 110; $i <= 139; $i++) - $this->fixture(Class_AvisNotice::class, ['id' => $i, - 'id_notice' => 1032, - 'entete' => 'Bulles n°' . $i, - 'note'=> 2, - 'id_user' => null, - 'flags' => 0, - 'avis' => $i . ' Pour faire aimer la biere aux enfants!', - 'abon_ou_bib' => 0, - 'date_avis' => $i, - 'id_notice' => 1032, - 'statut' => 1, - 'source_author' => null]); + for ($i = 110; $i <= 139; $i++) + $this->fixture(Class_AvisNotice::class, + ['id' => $i, + 'id_notice' => 1032, + 'entete' => 'Bulles n°' . $i, + 'note' => 2, + 'id_user' => null, + 'flags' => 0, + 'avis' => $i . ' Pour faire aimer la biere aux enfants!', + 'abon_ou_bib' => 0, + 'date_avis' => $i, + 'id_notice' => 1032, + 'statut' => 1, + 'source_author' => null]); } } + class ModoControllerIndexActionTest extends ModoControllerIndexActionTestCase { public function setUp() { parent::setUp(); - $this->dispatch('admin/modo/', true); + + $this->dispatch('admin/modo/'); } @@ -197,51 +210,56 @@ class ModoControllerIndexActionTest extends ModoControllerIndexActionTestCase { + abstract class ModoControllerTagnoticeTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - $this->fixture('Class_Notice', ['id' => 999, - 'titre_principal' => 'Captain Harlock', - 'facettes' => 'Z1 Z2 Z3']); - $this->fixture('Class_Notice', ['id' => 88, - 'titre_principal' => 'Captain Future', - 'facettes' => 'Z3']); + $this->fixture(Class_Notice::class, + ['id' => 999, + 'titre_principal' => 'Captain Harlock', + 'facettes' => 'Z1 Z2 Z3']); + + $this->fixture(Class_Notice::class, + ['id' => 88, + 'titre_principal' => 'Captain Future', + 'facettes' => 'Z3']); $this->fixTag(['id' => 1, - 'a_moderer' => ';999;', - 'notices' => ';999;', + 'a_moderer' => '999', + 'notices' => '999', 'libelle' => 'Manga', 'code_alpha' => 'MANGA']); $this->fixTag(['id' => 2, - 'a_moderer' => ';999;', - 'notices' => ';999;', + 'a_moderer' => '999', + 'notices' => '999', 'libelle' => 'Anime', 'code_alpha' => 'ANIME']); $this->fixTag(['id' => 3, - 'a_moderer' => ';999;88;', - 'notices' => ';999;88;', + 'a_moderer' => '999 88', + 'notices' => '999 88', 'libelle' => 'Années 80', 'code_alpha' => 'ANNEES 80']); } protected function fixTag($params) { - $this->fixture('Class_CodifTags', $params); - $this->fixture('Class_TagNotice', $params); + $this->fixture(Class_TagNotice::class, $params); } } + class ModoControllerTagnoticeActionTest extends ModoControllerTagnoticeTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('/admin/modo/tagnotice', true); + + $this->dispatch('/admin/modo/tagnotice'); } @@ -259,9 +277,12 @@ class ModoControllerTagnoticeActionTest extends ModoControllerTagnoticeTestCase + class ModoControllerUpdateTagnoticeActionTest extends ModoControllerTagnoticeTestCase { + public function setUp() { parent::setUp(); + $this->postDispatch('/admin/modo/updatetagnotice', ['tag' => ['1_1_999', '2_2_999', @@ -314,22 +335,22 @@ class ModoControllerUpdateTagnoticeActionTest extends ModoControllerTagnoticeTes + abstract class ModoControllerSuggestionAchatTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - $bib_orange = $this->fixture('Class_Bib', + $bib_orange = $this->fixture(Class_Bib::class, ['id' => 5, 'libelle' => 'Orange', 'mail_suggestion' => 'orange@abib.com']); - $bib_annecy = $this->fixture('Class_Bib', + $bib_annecy = $this->fixture(Class_Bib::class, ['id' => 3, 'libelle' => 'Annecy']); - $poucet = $this->fixture('Class_Users', + $poucet = $this->fixture(Class_Users::class, ['id' => 6, 'idabon' => '3435', 'prenom' => 'Petit', @@ -339,7 +360,7 @@ abstract class ModoControllerSuggestionAchatTestCase extends Admin_AbstractContr 'password' => 'pwd']); $poucet->beAbonneSIGB()->save(); - $duchamp = $this->fixture('Class_Users', + $duchamp = $this->fixture(Class_Users::class, ['id' => 10, 'idabon' => 0, 'prenom' => 'Marcel', @@ -348,7 +369,7 @@ abstract class ModoControllerSuggestionAchatTestCase extends Admin_AbstractContr 'password' => 'champ']); $duchamp->beInvite()->setBib($bib_annecy)->save(); - $this->fixture('Class_SuggestionAchat', + $this->fixture(Class_SuggestionAchat::class, ['id' => 2, 'date_creation' => '2012-03-01', 'titre' => 'Harry Potter', @@ -360,7 +381,7 @@ abstract class ModoControllerSuggestionAchatTestCase extends Admin_AbstractContr 'bib_id' => 5, 'user' => $poucet]); - $this->fixture('Class_SuggestionAchat', + $this->fixture(Class_SuggestionAchat::class, ['id' => 3, 'date_creation' => '2012-03-02', 'type_doc_id' => 1, @@ -370,7 +391,7 @@ abstract class ModoControllerSuggestionAchatTestCase extends Admin_AbstractContr 'auteur' => 'Stieg Larsson', 'user' => $poucet]); - $this->fixture('Class_SuggestionAchat', + $this->fixture(Class_SuggestionAchat::class, ['id' => 4, 'date_creation' => '2012-03-03', 'type_doc_id' => 1, @@ -383,10 +404,13 @@ abstract class ModoControllerSuggestionAchatTestCase extends Admin_AbstractContr + class ModoControllerSuggestionAchatActionTest extends ModoControllerSuggestionAchatTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('admin/modo/suggestion-achat', true); + + $this->dispatch('admin/modo/suggestion-achat'); } @@ -484,10 +508,13 @@ class ModoControllerSuggestionAchatActionTest extends ModoControllerSuggestionAc -class ModoControllerSuggestionAchatEditHarryPotterTest extends ModoControllerSuggestionAchatTestCase { +class ModoControllerSuggestionAchatEditHarryPotterTest + extends ModoControllerSuggestionAchatTestCase { + public function setUp() { parent::setUp(); - $this->dispatch('/admin/modo/suggestion-achat-edit/id/2', true); + + $this->dispatch('/admin/modo/suggestion-achat-edit/id/2'); } @@ -511,15 +538,18 @@ class ModoControllerSuggestionAchatEditHarryPotterTest extends ModoControllerSug + class ModoControllerSuggestionAchatEditUnknownTest extends ModoControllerSuggestionAchatTestCase { + public function setUp() { parent::setUp(); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SuggestionAchat') ->whenCalled('find') ->with(99) ->answers(null); - $this->dispatch('/admin/modo/suggestion-achat-edit/id/99', true); + $this->dispatch('/admin/modo/suggestion-achat-edit/id/99'); } @@ -531,7 +561,10 @@ class ModoControllerSuggestionAchatEditUnknownTest extends ModoControllerSuggest -class ModoControllerSuggestionAchatEditHarryPotterPostTest extends ModoControllerSuggestionAchatTestCase { + +class ModoControllerSuggestionAchatEditHarryPotterPostTest + extends ModoControllerSuggestionAchatTestCase { + public function setUp() { parent::setUp(); @@ -544,8 +577,7 @@ class ModoControllerSuggestionAchatEditHarryPotterPostTest extends ModoControlle /** @test */ public function errorForEmptyTitreAndCommentaireShouldBeTitreOuCommentaireRequis() { $this->postDispatch('/admin/modo/suggestion-achat-edit/id/2', - ['titre' => '', 'commentaire' => ''], - true); + ['titre' => '', 'commentaire' => '']); $this->assertXPathContentContains('//ul[@class="errors"]//li', 'Titre ou commentaire requis'); } @@ -554,15 +586,17 @@ class ModoControllerSuggestionAchatEditHarryPotterPostTest extends ModoControlle /** @test */ public function withValidDataShouldHaveNoError() { $this->postDispatch('/admin/modo/suggestion-achat-edit/id/2', - ['titre' => 'Star Wars', 'auteur' => 'G.Lucas', 'isbn' => '', 'type_doc_id' => 2], - true); + ['titre' => 'Star Wars', 'auteur' => 'G.Lucas', 'isbn' => '', 'type_doc_id' => 2]); $this->assertRedirect(); } } -class ModoControllerSuggestionAchatDeleteHarryPotterTest extends ModoControllerSuggestionAchatTestCase { + +class ModoControllerSuggestionAchatDeleteHarryPotterTest + extends ModoControllerSuggestionAchatTestCase { + public function setUp() { parent::setUp(); @@ -570,7 +604,7 @@ class ModoControllerSuggestionAchatDeleteHarryPotterTest extends ModoControllerS ->whenCalled('delete') ->answers(null); - $this->dispatch('admin/modo/suggestion-achat-delete/id/2', true); + $this->dispatch('admin/modo/suggestion-achat-delete/id/2'); } @@ -588,15 +622,18 @@ class ModoControllerSuggestionAchatDeleteHarryPotterTest extends ModoControllerS + class ModoControllerSuggestionAchatDeleteUnknownTest extends ModoControllerSuggestionAchatTestCase { + public function setUp() { parent::setUp(); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_SuggestionAchat') ->whenCalled('find') ->with(99) ->answers(null); - $this->dispatch('admin/modo/suggestion-achat-delete/id/99', true); + $this->dispatch('admin/modo/suggestion-achat-delete/id/99'); } @@ -607,21 +644,24 @@ class ModoControllerSuggestionAchatDeleteUnknownTest extends ModoControllerSugge } + + abstract class ModoControllerEditAvisCmsTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - $this->fixture('Class_Avis', + $this->fixture(Class_Avis::class, ['id' => 1, 'date_avis' => '2014-04-16', - 'user' => $this->fixture('Class_Users', ['id' => 45, - 'login' => 'biquette', - 'password' => 'mysecret']), - 'article' => $this->fixture('Class_Article', ['id' => 2, - 'titre' => 'Coucou la biquette', - 'contenu' => 'plop plop']), + 'user' => $this->fixture(Class_Users::class, + ['id' => 45, + 'login' => 'biquette', + 'password' => 'mysecret']), + 'article' => $this->fixture(Class_Article::class, + ['id' => 2, + 'titre' => 'Coucou la biquette', + 'contenu' => 'plop plop']), 'avis' => "Yes you can !", 'entete' => 'Can you accept my merge request ?', 'note' => '3', @@ -632,39 +672,46 @@ abstract class ModoControllerEditAvisCmsTestCase extends Admin_AbstractControlle + class ModoControllerIndexAvisCmsTest extends ModoControllerEditAvisCmsTestCase { + /** @test **/ public function avisShouldHaveEditLink() { - $this->dispatch('admin/modo/aviscms', true); + $this->dispatch('admin/modo/aviscms'); $this->assertXPath('//a[contains(@href, "/modo/edit-aviscms/id/1")]'); } } + + class ModoControllerEditAvisCmsTest extends ModoControllerEditAvisCmsTestCase { + /** @test **/ public function textAreaShouldContainsThisIsATest() { - $this->dispatch('admin/modo/edit-aviscms/id/1', true); + $this->dispatch('admin/modo/edit-aviscms/id/1'); $this->assertXPathContentContains('//textarea[@id="avis"]', 'Yes you can !'); } /** @test **/ public function inputTextShouldContainsCanYouAcceptMyMergeRequest() { - $this->dispatch('admin/modo/edit-aviscms/id/1', true); + $this->dispatch('admin/modo/edit-aviscms/id/1'); $this->assertXPath('//input[@type="text"][@id="entete"][@value="Can you accept my merge request ?"]'); } } + class ModoControllerEditAvisCmsPostTest extends ModoControllerEditAvisCmsTestCase { + public function setUp() { parent::setUp(); + $this->postDispatch('admin/modo/edit-aviscms/id/1', ['avis' => 'Ceci est un avis de test modifié!', 'entete' => 'w00t !']); - } @@ -682,19 +729,20 @@ class ModoControllerEditAvisCmsPostTest extends ModoControllerEditAvisCmsTestCas + class ModoControllerDeleteAvisCmsTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - $this->fixture('Class_Article', ['id' => 28, - 'titre' => 'test', - 'contenu' => 'test']); + $this->fixture(Class_Article::class, + ['id' => 28, + 'titre' => 'test', + 'contenu' => 'test']); - $this->fixture('Class_Avis', + $this->fixture(Class_Avis::class, ['id' => 34, - 'auteur' => $this->fixture('Class_Users', + 'auteur' => $this->fixture(Class_Users::class, ['id' => 98, 'login' => 'mimi', 'password' => 'secret', @@ -711,8 +759,7 @@ class ModoControllerDeleteAvisCmsTest extends Admin_AbstractControllerTestCase { ->whenCalled('delete') ->answers(true); - - $this->dispatch('admin/modo/delete-cms-avis/id/34', true); + $this->dispatch('admin/modo/delete-cms-avis/id/34'); } @@ -732,31 +779,33 @@ class ModoControllerDeleteAvisCmsTest extends Admin_AbstractControllerTestCase { class ModoControllerAvisNoticeHTTPErrorOnGetVignetteTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true, - $_http_client; - public function setup() { - parent::setup(); + protected $_http_client; + + public function setUp() { + parent::setUp(); + Class_AdminVar::set('AVIS_MIN_SAISIE', 1); Class_AdminVar::set('AVIS_MAX_SAISIE', 100); - $this->fixture(Class_AvisNotice::class, ['id' => 622, - 'id_notice' => 10, - 'entete' => 'Orphan Test', - 'note'=> 2, - 'id_user' => null, - 'flags' => 1, - 'avis' => 'Un bon livre !', - 'statut' => 0, - 'abon_ou_bib' => 1, - 'source_author' => null]); - - $this->fixture('Class_Profil', + $this->fixture(Class_AvisNotice::class, + ['id' => 622, + 'id_notice' => 10, + 'entete' => 'Orphan Test', + 'note' => 2, + 'id_user' => null, + 'flags' => 1, + 'avis' => 'Un bon livre !', + 'statut' => 0, + 'abon_ou_bib' => 1, + 'source_author' => null]); + + $this->fixture(Class_Profil::class, ['id' => 1, 'libelle' => 'default profil']) ->beCurrentProfil(); - $this->fixture('Class_Notice', - ['id'=> 10, + $this->fixture(Class_Notice::class, + ['id' => 10, 'titre_principal' => 'Le photographe', 'auteur_principal' => 'Guibert', 'isbn' => '3222222', @@ -765,13 +814,13 @@ class ModoControllerAvisNoticeHTTPErrorOnGetVignetteTest extends Admin_AbstractC 'clef_alpha' => 'LEPHOOGRAPHE--GUIBERT---2004-1', 'type_doc' => 'ArteVod']); - $this->fixture('Class_Exemplaire', - ['id'=> 10, - 'id_notice'=> 10, + $this->fixture(Class_Exemplaire::class, + ['id' => 10, + 'id_notice' => 10, 'id_origine' => 42, 'type' => 'ArteVod']); - $this->fixture('Class_Album', + $this->fixture(Class_Album::class, ['id' => 42, 'titre' => 'Le Photographe', 'fichier' => 'potter.jpg', @@ -781,13 +830,13 @@ class ModoControllerAvisNoticeHTTPErrorOnGetVignetteTest extends Admin_AbstractC $this->_http_client = $this->mock() ->whenCalled('getResponse') - ->willDo( function () - { - throw new \Exception('Unable to connect to webservice'); - }); + ->willDo(function () + { + throw new \Exception('Unable to connect to webservice'); + }); Class_WebService_Vignette::setDefaultHttpClient($this->_http_client); - $this->dispatch('admin/modo/avisnotice', true); + $this->dispatch('admin/modo/avisnotice'); } @@ -813,27 +862,27 @@ class ModoControllerAvisNoticeHTTPErrorOnGetVignetteTest extends Admin_AbstractC class ModoControllerAvisnoticeActionTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - public function setup() { - parent::setup(); + public function setUp() { + parent::setUp(); Class_AdminVar::set('AVIS_MIN_SAISIE', 1); Class_AdminVar::set('AVIS_MAX_SAISIE', 100); - $this->fixture(Class_AvisNotice::class, ['id' => 622, - 'id_notice' => 1002, - 'entete' => 'Orphan Test', - 'note'=> 2, - 'id_user' => null, - 'flags' => 1, - 'avis' => 'Un bon livre !', - 'id_notice' => 1032, - 'statut' => 0, - 'abon_ou_bib' => 1, - 'source_author' => null]); + $this->fixture(Class_AvisNotice::class, + ['id' => 622, + 'id_notice' => 1002, + 'entete' => 'Orphan Test', + 'note' => 2, + 'id_user' => null, + 'flags' => 1, + 'avis' => 'Un bon livre !', + 'id_notice' => 1032, + 'statut' => 0, + 'abon_ou_bib' => 1, + 'source_author' => null]); - $this->dispatch('admin/modo/avisnotice', true); + $this->dispatch('admin/modo/avisnotice'); } @@ -866,6 +915,7 @@ class ModoControllerAvisnoticeActionTest extends Admin_AbstractControllerTestCas $this->assertXPathContentContains('//a', 'Afficher tous les avis modérés'); } + /** @test */ public function buttonToModerateOrphanReviewsShouldBeDisplayed() { $this->assertXPathContentContains('//button[contains(@data-url,"admin/modo/manage-orphan-reviews")]', 'Gérer les avis orphelins'); @@ -876,15 +926,14 @@ class ModoControllerAvisnoticeActionTest extends Admin_AbstractControllerTestCas abstract class ModoControllerOrphanReviewsTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - public function setUp() { parent::setUp(); + $this->fixture(Class_AvisNotice::class, - [ 'id' => 2, + ['id' => 2, 'entete' => 'Orphan Test', - 'note'=> 2, + 'note' => 2, 'clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', 'id_user' => null, 'flags' => 1, @@ -895,9 +944,9 @@ abstract class ModoControllerOrphanReviewsTestCase extends Admin_AbstractControl ]); $this->fixture(Class_AvisNotice::class, - [ 'id' => 5, + ['id' => 5, 'entete' => 'Orphan Test 2', - 'note'=> 5, + 'note' => 5, 'clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', 'id_user' => null, 'flags' => 1, @@ -908,9 +957,9 @@ abstract class ModoControllerOrphanReviewsTestCase extends Admin_AbstractControl ]); $this->fixture(Class_AvisNotice::class, - [ 'id' => 6, + ['id' => 6, 'entete' => 'Orphan Test 3', - 'note'=> 3, + 'note' => 3, 'clef_oeuvre' => '15QUINZEJOURSSANSRESEAU--RIGALGOULARDS-', 'id_user' => null, 'flags' => 1, @@ -920,7 +969,7 @@ abstract class ModoControllerOrphanReviewsTestCase extends Admin_AbstractControl 'source_author' => null ]); - $this->fixture('Class_Notice', + $this->fixture(Class_Notice::class, ['id' => 429, 'clef_alpha' => "LESVAMPIRESDEMANHATTAN--DELACRUZM-1-ALBINMICHEL-2007-1", 'clef_oeuvre' => "LESVAMPIRESDEMANHATTAN--DELACRUZM-1-ALBINMICHEL-2007-1", @@ -937,17 +986,19 @@ abstract class ModoControllerOrphanReviewsTestCase extends Admin_AbstractControl class ModoControllerManageOrphanReviewsTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; - public function setup(){ - parent::setup(); + public function setUp(){ + parent::setUp(); + Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') ->answers([['clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', 'cnt'=> 2]])); + $this->dispatch('/admin/modo/manage-orphan-reviews'); } + /** @test */ public function titleShouldBeManageOrphanReviews() { $this->assertXPathContentContains('//h1','Gérer les avis orphelins'); @@ -959,6 +1010,7 @@ class ModoControllerManageOrphanReviewsTest extends ModoControllerOrphanReviewsT $this->assertXPathContentContains('//button[@data-url="/admin/modo/resync-title-orphan-reviews"]','Resynchroniser les titres pour les avis ayant des notices liées'); } + /** @test */ public function tabletdShouldContainsLESVAMPIRESDEMANHATTAN() { $this->assertXPathContentContains('//td','LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-'); @@ -989,10 +1041,10 @@ class ModoControllerManageOrphanReviewsTest extends ModoControllerOrphanReviewsT class ModoControllerDeleteOrphanReviewsTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); + $this->dispatch('/admin/modo/delete-orphan-reviews/id/LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-'); } @@ -1013,10 +1065,10 @@ class ModoControllerDeleteOrphanReviewsTest extends ModoControllerOrphanReviewsT class ModoControllerDeleteOrphanReviewsNoParamTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); + $this->dispatch('/admin/modo/delete-orphan-reviews/id/'); } @@ -1030,11 +1082,12 @@ class ModoControllerDeleteOrphanReviewsNoParamTest extends ModoControllerOrphanR -class ModoControllerDeleteOrphanReviewsNoReviewFoundTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; +class ModoControllerDeleteOrphanReviewsNoReviewFoundTest + extends ModoControllerOrphanReviewsTestCase { public function setUp() { parent::setUp(); + $this->dispatch('/admin/modo/delete-orphan-reviews/id/WTF31516--DELACRUZM-'); } @@ -1049,10 +1102,10 @@ class ModoControllerDeleteOrphanReviewsNoReviewFoundTest extends ModoControllerO class ModoControllerRelinkOrphanReviewsTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); + $this->dispatch('/admin/modo/relink-orphan-reviews/id/LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-'); } @@ -1079,11 +1132,11 @@ class ModoControllerRelinkOrphanReviewsTest extends ModoControllerOrphanReviewsT class ModoControllerRelinkOrphanReviewsPostTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); - $this->fixture('Class_Notice', + + $this->fixture(Class_Notice::class, ['id' => 429, 'clef_alpha' => "LESVAMPIRESDEMANHATTAN--DELACRUZM-1-ALBINMICHEL-2007-1", 'clef_oeuvre' => "LESVAMPIRESDEMANHATTAN--DELACRUZM-1-ALBINMICHEL-2007-1", @@ -1105,6 +1158,7 @@ class ModoControllerRelinkOrphanReviewsPostTest extends ModoControllerOrphanRevi $this->assertRedirectTo('/admin/modo/manage-orphan-reviews'); } + /** @test */ public function notifyShouldBeGereLaLiaisonNoticeDesAvis() { $this->assertFlashMessengerContentContains('2 avis contenant la clé oeuvre "LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-" rattaché(s) à la notice "Les Vampires de Manhattan"'); @@ -1127,20 +1181,19 @@ class ModoControllerRelinkOrphanReviewsPostTest extends ModoControllerOrphanRevi class ModoControllerResyncTitleOrphanReviewsTest extends ModoControllerOrphanReviewsTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); $reviews = Class_AvisNotice::findAllBy(['clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-']); /** - @see http://forge.afi-sa.fr/issues/160884 - */ + @see http://forge.afi-sa.fr/issues/160884 + */ $reviews[0] - ->setEntete('') - ->setAvis('') - ->beImportMode() - ->save(); + ->setEntete('') + ->setAvis('') + ->beImportMode() + ->save(); foreach ($reviews as $review) $review->setIdNotice(429)->save(); @@ -1148,6 +1201,7 @@ class ModoControllerResyncTitleOrphanReviewsTest extends ModoControllerOrphanRev Zend_Registry::set('sql', $this->mock() ->whenCalled('fetchAll') ->answers([[ 'id' => 2 ],[ 'id' => 5 ]])); + $this->dispatch('/admin/modo/resync-title-orphan-reviews'); } @@ -1157,6 +1211,7 @@ class ModoControllerResyncTitleOrphanReviewsTest extends ModoControllerOrphanRev $this->assertRedirectTo('/admin/modo/manage-orphan-reviews'); } + /** @test */ public function notifyShouldBeGereLaLiaisonNoticeDesAvis() { $this->assertFlashMessengerContentContains('2 avis resynchronisés avec les notices'); @@ -1180,9 +1235,10 @@ class ModoControllerResyncTitleOrphanReviewsTest extends ModoControllerOrphanRev class ModoControllerAllReviewsActionTest extends ModoControllerIndexActionTestCase { - public function setup() { - parent::setup(); - $this->dispatch('admin/modo/avisnotice/status/1', true); + public function setUp() { + parent::setUp(); + + $this->dispatch('admin/modo/avisnotice/status/1'); } @@ -1218,46 +1274,38 @@ class ModoControllerAllReviewsActionTest extends ModoControllerIndexActionTestCa -class ModoControllerAllReviewsPageActionTest extends ModoControllerIndexActionTestCase { - - public function setup() { - parent::setup(); - } +class ModoControllerAllReviewsPageActionTest extends ModoControllerIndexActionTestCase { /** @test **/ public function moderatedReviewsShouldBeDisplayedEvenIfPageIsOutOfBound() { - $this->dispatch('admin/modo/avisnotice/status/1/page/10', true); + $this->dispatch('admin/modo/avisnotice/status/1/page/10'); $this->assertXpathContentContains('//div//h2', 'B comme bière : la bière expliquée aux (grands) enfants'); } /** @test **/ public function page3ShouldNotConstainsTheLastReviewSaved139() { - $this->dispatch('admin/modo/avisnotice/status/1/page/3/active_tab/1', true); + $this->dispatch('admin/modo/avisnotice/status/1/page/3/active_tab/1'); $this->assertNotXpathContentContains('//div[@class="critique"]//div[@class="contenu_critique"]//a[contains(@href, "blog/viewavis")]', '139'); } /** @test */ public function page1ShouldContains10Reviews() { - $this->dispatch('admin/modo/avisnotice/status/1/page/1/active_tab/1', true); + $this->dispatch('admin/modo/avisnotice/status/1/page/1/active_tab/1'); $this->assertXPathContentContains('//div[2]/span', 'résultats sur cette page.'); } } -class ModoControllerArchivedReviewsActionTest extends ModoControllerIndexActionTestCase { - - public function setup() { - parent::setup(); - } +class ModoControllerArchivedReviewsActionTest extends ModoControllerIndexActionTestCase { /** @test **/ public function moderatedReviewsShouldBeArchived() { - $this->dispatch('admin/modo/invisibleavisnotice/id/223', true); + $this->dispatch('admin/modo/invisibleavisnotice/id/223'); $this->assertEquals(2,Class_AvisNotice::find(223)->getFlags()); } @@ -1267,7 +1315,7 @@ class ModoControllerArchivedReviewsActionTest extends ModoControllerIndexActionT $avis=(Class_AvisNotice::find(223)); $avis->setFlags(2); $avis->save(); - $this->dispatch('admin/modo/visibleavisnotice/id/223', true); + $this->dispatch('admin/modo/visibleavisnotice/id/223'); $this->assertEquals(0,Class_AvisNotice::find(223)->getFlags()); } } @@ -1278,8 +1326,6 @@ class ModoControllerArchivedReviewsActionTest extends ModoControllerIndexActionT /** @see https://forge.afi-sa.net/issues/142363 */ class ModoControllerWithoutUserTest extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - public function setUp() { parent::setUp(); @@ -1303,8 +1349,8 @@ class ModoControllerWithoutUserTest extends Admin_AbstractControllerTestCase { -class ModoControllerRelinkOrphanReviewsPostWithNoDoubleSearchModeTest extends ModoControllerOrphanReviewsTestCase { - +class ModoControllerRelinkOrphanReviewsPostWithNoDoubleSearchModeTest + extends ModoControllerOrphanReviewsTestCase { public function setUp() { parent::setUp(); @@ -1320,24 +1366,23 @@ class ModoControllerRelinkOrphanReviewsPostWithNoDoubleSearchModeTest extends Mo 'id_int_bib' => 1, 'id_origine' => 7890])]); /* - @see http://forge.afi-sa.fr/issues/160884 + @see http://forge.afi-sa.fr/issues/160884 */ $this->fixture(Class_AvisNotice::class, [ 'id' => 15, - 'entete' => '', - 'note'=> 5, - 'clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', - 'id_user' => null, - 'flags' => 1, - 'avis' => '', - 'statut' => 1, - 'abon_ou_bib' => 1, - 'source_author' => null, - '_import_mode' => true + 'entete' => '', + 'note' => 5, + 'clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', + 'id_user' => null, + 'flags' => 1, + 'avis' => '', + 'statut' => 1, + 'abon_ou_bib' => 1, + 'source_author' => null, + '_import_mode' => true ]) ->setImportMode(false); - $this->postDispatch('/admin/modo/relink-orphan-reviews/id/LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', ['clef_oeuvre' => 'LESVAMPIRESDEMANHATTANTOME1--DELACRUZM-', 'url' => Class_Url::absolute('/recherche/viewnotice/id_sigb/7890/id_int_bib/1')]); diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index 1f495a68cccd4e4d24cf3117d6f9fadccd7e6011..69adff05c6d8b2c339879684394739e69ea4973a 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -1280,11 +1280,62 @@ class Admin_ProfilControllerCopyProfilJeunesseTest extends Admin_ProfilControlle -class Admin_ProfilControllerDeepCopyProfilJeunesseTest extends Admin_ProfilControllerProfilJeunesseWithPagesTestCase { +class Admin_ProfilControllerDeepCopyProfilJeunesseTest + extends Admin_ProfilControllerProfilJeunesseWithPagesTestCase +{ + + protected Class_Profil $_profil_mock; + + public function setUp() + { + parent::setUp(); + + $this->_profil_mock = new class() extends Class_Profil + { + + public function getId() + { + return 7; + } + + + public function clearInstanceCache() + { + return $this; + } + + + public function isPublic() + { + return true; + } + + + public function deepCopy() { + return new class() extends Class_Profil + { + + public function save($force_primary_key = false) + { + return false; + } + + + public function getErrors() + { + return ['something unexpected happened']; + } + }; + } + }; + } + + /** @test */ - public function withoutErrorShouldRedirectToEditProfilWithNewId() { + public function withoutErrorShouldRedirectToEditProfilWithNewId() + { $max_id = Class_Profil::findFirstBy(['order' => 'id desc'])->getId(); - $this->dispatch('/admin/profil/deep_copy/id_profil/5', true); + $this->dispatch('/admin/profil/deep_copy/id_profil/5'); $this->assertRedirectTo('/admin/profil/edit/id_profil/'.($max_id+1), $this->getResponseLocation()); @@ -1292,18 +1343,9 @@ class Admin_ProfilControllerDeepCopyProfilJeunesseTest extends Admin_ProfilContr /** @test */ - public function withErrorShouldRedirectToIndexAndNotify() { - $profil_mock = (new Class_Entity(['Id' => 7])) - ->whenCalledDo('clearInstanceCache', function() {}) - ->whenCalledDo('isPublic', function() {return true;}) - ->whenCalledDo('deepCopy', function() - { - return Storm_Test_ObjectWrapper::mock() - ->whenCalled('save')->answers(false) - ->whenCalled('getErrors')->answers(['something unexpected happened']); - }); - - Class_Profil::getLoader()->cacheInstance($profil_mock); + public function withErrorShouldRedirectToIndexAndNotify() + { + Class_Profil::getLoader()->cacheInstance($this->_profil_mock); $this->dispatch('/admin/profil/deepcopy/id_profil/7'); $this->assertRedirectTo('/admin/profil', $this->getResponseLocation()); diff --git a/tests/application/modules/opac/controllers/AbonneControllerTagNoticeTest.php b/tests/application/modules/opac/controllers/AbonneControllerTagNoticeTest.php index cd07636ad6f87f827fda970a6db49584853a4a01..24e3d0be2c53bcd29a3b7324743e07cd292bd558 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerTagNoticeTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerTagNoticeTest.php @@ -222,13 +222,13 @@ class AbonneControllerTagNoticePopupAddValidPostTest /** @test */ public function tagsShouldHaveLinkToRecord() { - $this->_withTagsDo(fn($tag) => $this->assertContains(';23;', $tag->getNotices())); + $this->_withTagsDo(fn($tag) => $this->assertContains('23', $tag->getNotices())); } /** @test */ public function tagsShouldHaveLinkToModerateRecord() { - $this->_withTagsDo(fn($tag) => $this->assertContains(';23;', + $this->_withTagsDo(fn($tag) => $this->assertContains('23', $tag->getAModerer())); } diff --git a/tests/application/modules/opac/controllers/BlogControllerTest.php b/tests/application/modules/opac/controllers/BlogControllerTest.php index c43834079766cc701ebab9a43ce69e587eeb048a..1e94dd8f91a661ab5110a0b6b3f41472eb10538b 100644 --- a/tests/application/modules/opac/controllers/BlogControllerTest.php +++ b/tests/application/modules/opac/controllers/BlogControllerTest.php @@ -111,6 +111,7 @@ class BlogControllerHierarchicalTest extends AbstractControllerTestCase { $this->assertSqlEquals(["SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'Catalogue' AND `codif_thesaurus`.`id_thesaurus` LIKE 'CCCC0001%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", "SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'Catalogue' AND `codif_thesaurus`.`id_thesaurus` LIKE 'CCCC00010001%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", "SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'Catalogue' AND `codif_thesaurus`.`id_thesaurus` LIKE 'CCCC00010002%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", + "SELECT `codif_tags`.* FROM `codif_tags` WHERE (`codif_tags`.`a_moderer` > '')", "SELECT `avis_notices`.`id` FROM `notices_avis` AS `avis_notices` INNER JOIN `notices` ON `avis_notices`.`clef_oeuvre` = `notices`.`clef_oeuvre` AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_Zjeuxvideo' IN BOOLEAN MODE) AND `notices`.`type` = 1 WHERE (`avis_notices`.`flags` = 0) ORDER BY `avis_notices`.`date_avis` DESC LIMIT 2", "SELECT `notices_avis`.* FROM `notices_avis` WHERE (`notices_avis`.`id` IN (2, 1)) ORDER BY `notices_avis`.`date_avis` DESC"]); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php index 38279d32e1354b56501a8cc188f5a8d3e90aa82b..fcf771d63b134b1aef8cfd93cb56c7db21389450 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerReservationTest.php @@ -25,7 +25,6 @@ abstract class RechercheControllerReservationTestCase protected $_json, $_xpath; - public function setUp() { parent::setUp(); @@ -44,7 +43,7 @@ abstract class RechercheControllerReservationTestCase 'id_origine' => '37', 'libelle' => 'Cran']); - $this->_xpath = new Storm_Test_XPath(); + $this->_xpath = new Storm_Test_XPath; } } @@ -56,6 +55,7 @@ abstract class RechercheControllerReservationWithPickupChoiceTestCase public function setUp() { parent::setUp(); + Class_CosmoVar::setValueOf('site_retrait_resa', Class_CosmoVar::PICKUP_LOCATION_CHOICE); } @@ -70,7 +70,7 @@ class RechercheControllerReservationPickupAjaxActionWithChosenPickupTest public function setUp() { parent::setUp(); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36',true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36'); $this->_json = json_decode($this->_response->getBody()); } @@ -79,7 +79,8 @@ class RechercheControllerReservationPickupAjaxActionWithChosenPickupTest /** @test */ public function shouldRenderAnnecyCheckedRadio() { $this->_xpath->assertXPath($this->_json->content, - '//input[@name="code_annexe"][@value="36"][@checked="checked"]',$this->_json->content); + '//input[@name="code_annexe"][@value="36"][@checked="checked"]', + $this->_json->content); } @@ -102,7 +103,6 @@ class RechercheControllerReservationPickupAjaxActionWithChosenPickupTest class RechercheControllerReservationPickupAjaxActionPostTest extends RechercheControllerReservationWithPickupChoiceTestCase { - /** @test */ public function responseShouldRedirectToReservationajaxAction() { $this->postDispatch('recherche/reservation-pickup-ajax', @@ -171,13 +171,13 @@ class RechercheControllerReservationPickupAjaxActionTestWithChosenPickupDispatch parent::setUp(); $bib = $this - ->fixture('Class_IntBib', + ->fixture(Class_IntBib::class, ['id' => 1, 'comm_sigb' => Class_IntBib::COM_NANOOK, 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]); $this->jajm = $this - ->fixture('Class_Users', + ->fixture(Class_Users::class, ['id' => 1, 'login' => 'jajm', 'password' => 'secret', @@ -201,7 +201,7 @@ class RechercheControllerReservationPickupAjaxActionTestWithChosenPickupDispatch $mock_transport = new MockMailTransport(); Zend_Mail::setDefaultTransport($mock_transport); - $this->dispatch('recherche/reservationajax/id/11760/id_int_bib/23/id_bib/23/id_origine/594105/code_annexe/23/render/popup/copy_id/12', true); + $this->dispatch('recherche/reservationajax/id/11760/id_int_bib/23/id_bib/23/id_origine/594105/code_annexe/23/render/popup/copy_id/12'); $this->_sent_mails = $mock_transport->getSentMails(); } @@ -210,7 +210,7 @@ class RechercheControllerReservationPickupAjaxActionTestWithChosenPickupDispatch /** @test */ public function parameterCodeAnnexeShouldBeUsedForReservation() { $this->assertEquals('23', - $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); + $this->nanook->getAttributesForLastCallOn('reserverExemplaire')[2]); } @@ -230,19 +230,19 @@ class RechercheControllerReservationPickupAjaxActionTestWithPatronLibraryPickup parent::setUp(); $bib = $this - ->fixture('Class_IntBib', + ->fixture(Class_IntBib::class, ['id' => 12, 'comm_sigb' => Class_IntBib::COM_NANOOK, 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]); - $this->jajm = $this->fixture('Class_Users', + $this->jajm = $this->fixture(Class_Users::class, ['id' => 1, 'login' => 'jajm', 'password' => 'secret', 'idabon' => '0000007', 'int_bib' => $bib]); - $this->nanook = (new Class_Testing_WebService_SIGB_Nanook_Service()) + $this->nanook = (new Class_Testing_WebService_SIGB_Nanook_Service) ->whenCalled('isConnected')->answers(true) ->whenCalled('providesPickupLocations')->answers(false) ->whenCalled('getUserAnnexe')->answers('12'); @@ -257,9 +257,10 @@ class RechercheControllerReservationPickupAjaxActionTestWithPatronLibraryPickup Class_CosmoVar::setValueOf('site_retrait_resa', Class_CosmoVar::PICKUP_LOCATION_PATRON); - $this->fixture('Class_Exemplaire', ['id' => 12]); + $this->fixture(Class_Exemplaire::class, + ['id' => 12]); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36©_id=12', true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36©_id=12'); } @@ -311,7 +312,7 @@ class RechercheControllerReservationPickupAjaxActionTestWithItemLibraryPickup ['id' => 12, 'annexe' => 36]); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36©_id=12', true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=36©_id=12'); } @@ -327,9 +328,8 @@ class RechercheControllerReservationPickupAjaxActionTestWithItemLibraryPickup class RechercheControllerReservationWithMailPostAction extends AbstractControllerTestCase { - protected - $_sent_mails, - $_storm_default_to_volatile = true; + + protected $_sent_mails; public function setUp() { parent::setUp(); @@ -339,12 +339,14 @@ class RechercheControllerReservationWithMailPostAction $mock_transport = new MockMailTransport(); Zend_Mail::setDefaultTransport($mock_transport); - $this->fixture('Class_Bib', ['id' => 4, - 'libelle' => 'Astrolabe', - 'mail' => 'zork@gloub.fr',]); + $this->fixture(Class_Bib::class, + ['id' => 4, + 'libelle' => 'Astrolabe', + 'mail' => 'zork@gloub.fr',]); - $this->fixture('Class_Notice', ['id' => 4, - 'unimarc' => "01570nam0 2200325 450 0010007000000100033000070200017000400210027000571000041000841010008001251020007001331050018001401060006001582000106001642100075002702150044003452250023003893000125004123000020005373000137005573300265006943450018009594100051009775120027010286060033010556060060010886760012011487000045011608010039012052218529 a2-86642-370-4bbr.d8,95 EUR aFRb00347575 aFRbDLE-20031204-51138 a20031107d2003 m h0frey0103 ba| afre aFR ay z 000y| ar1 aCinema d'animationbTexte impriméedessin animé, marionnettes, images de synthèsefBernard Genin a[Paris]c\"Cahiers du cinéma\"cSCEREN-CNDPdcop. 2003gimpr. en Italie a95 p.cill., couv. ill. en coul.d19 cm2 aLes petits cahiers aLa couv. porte en plus : \"du crayon à l'ordinateur, pour ou contre Disney, Europe-Japon : le dessin animé aujourd'hui\" aBibliogr. p. 93 aSCEREN = Services, cultures, éditions, ressources pour l'éducation nationale. CNDP = Centre national de documentation pédagogique aPrésente un historique du cinéma d'animation, un survol des différentes productions nationales à travers le monde (Etats-Unis, Japon, France, Canada), les techniques du volume animé, l'image de synthèse, mais aussi l'oeuvre de Disney et le film d'auteur. b9782866423704 032525826tLes Petits cahiers (Paris)x1633-90531 aLe cinéma d'animation| 31053394aAnimation (cinéma)| 31031625aDessins animés32195497xHistoire et critique a791.431 |32547161aGeninbBernardf1946-....4070 0aFRbBNFc20031107gAFNOR2intermrc"]); + $this->fixture(Class_Notice::class, + ['id' => 4, + 'unimarc' => "01570nam0 2200325 450 0010007000000100033000070200017000400210027000571000041000841010008001251020007001331050018001401060006001582000106001642100075002702150044003452250023003893000125004123000020005373000137005573300265006943450018009594100051009775120027010286060033010556060060010886760012011487000045011608010039012052218529 a2-86642-370-4bbr.d8,95 EUR aFRb00347575 aFRbDLE-20031204-51138 a20031107d2003 m h0frey0103 ba| afre aFR ay z 000y| ar1 aCinema d'animationbTexte impriméedessin animé, marionnettes, images de synthèsefBernard Genin a[Paris]c\"Cahiers du cinéma\"cSCEREN-CNDPdcop. 2003gimpr. en Italie a95 p.cill., couv. ill. en coul.d19 cm2 aLes petits cahiers aLa couv. porte en plus : \"du crayon à l'ordinateur, pour ou contre Disney, Europe-Japon : le dessin animé aujourd'hui\" aBibliogr. p. 93 aSCEREN = Services, cultures, éditions, ressources pour l'éducation nationale. CNDP = Centre national de documentation pédagogique aPrésente un historique du cinéma d'animation, un survol des différentes productions nationales à travers le monde (Etats-Unis, Japon, France, Canada), les techniques du volume animé, l'image de synthèse, mais aussi l'oeuvre de Disney et le film d'auteur. b9782866423704 032525826tLes Petits cahiers (Paris)x1633-90531 aLe cinéma d'animation| 31053394aAnimation (cinéma)| 31031625aDessins animés32195497xHistoire et critique a791.431 |32547161aGeninbBernardf1946-....4070 0aFRbBNFc20031107gAFNOR2intermrc"]); $this->postDispatch('/recherche/reservation/id_notice/4/id_bib/4/cote/XYZ', ['user_name' => 'nanuk', @@ -418,18 +420,17 @@ class RechercheControllerReservationWithMailPostAction class RechercheControllerReservationWithWebServiceKohaTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; public function setUp() { parent::setUp(); $webservice = 'http://bib.valensol.net'; - $bib = $this->fixture('Class_IntBib', + $bib = $this->fixture(Class_IntBib::class, ['id' => 1, 'comm_sigb' => Class_IntBib::COM_KOHA_LEGACY, 'comm_params' => ['url_serveur' => $webservice]]); - $this->jajm = $this->fixture('Class_Users', + $this->jajm = $this->fixture(Class_Users::class, ['id' => 1, 'login' => 'jajm', 'password' => 'secret', @@ -441,15 +442,14 @@ class RechercheControllerReservationWithWebServiceKohaTest $this->koha->setServerRoot( $webservice); Class_WebService_SIGB_KohaLegacy::setService(['url_serveur' => $webservice, - 'id_bib' => 1, - 'type' => Class_IntBib::COM_KOHA_LEGACY], - $this->koha); + 'id_bib' => 1, + 'type' => Class_IntBib::COM_KOHA_LEGACY], + $this->koha); } protected function dispatchAndCheckContentEquals($expected) { - $this->dispatch('/recherche/reservationajax/id_bib/1/copy_id/456/code_annexe/VS', - true); + $this->dispatch('/recherche/reservationajax/id_bib/1/copy_id/456/code_annexe/VS'); $this->json = json_decode($this->_response->getBody()); $this->assertEquals($expected, $this->json->content); } @@ -476,9 +476,9 @@ class RechercheControllerReservationWithWebServiceKohaTest $this->koha ->whenCalledDo('reserverExemplaire', [], function() - { - return $this->_error('error'); - }); + { + return $this->_error('error'); + }); $this->dispatch('/recherche/reservationajax/id_bib/1/copy_id/456/code_annexe/VS'); @@ -511,40 +511,40 @@ class RechercheControllerReservationWithWebServiceKohaTest 'titre_principal' => 'Albator <br /> Arcadia', 'auteur_principal' => 'Matsumoto'])]); $this->_dispatchWithEmprunteurAndAssertContentEquals( - $this->_prepareEmprunteurHolding($exemplaire, 'Valensole'), - 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document \'Albator Arcadia / Matsumoto\' sera disponible pour être retiré à : Valensole'); + $this->_prepareEmprunteurHolding($exemplaire, 'Valensole'), + 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document \'Albator Arcadia / Matsumoto\' sera disponible pour être retiré à : Valensole'); } /** @test */ public function withMatchingHoldAndRecordWithoutAuthorMessageShouldContainsPickupLocationAndRecordTitleOnly() { - $exemplaire = $this->fixture('Class_Exemplaire', + $exemplaire = $this->fixture(Class_Exemplaire::class, ['id' => 456, 'code_barres' => 123, 'id_int_bib' => 1, - 'notice' => $this->fixture('Class_Notice', + 'notice' => $this->fixture(Class_Notice::class, ['id' => 8890, 'titre_principal' => 'Arcadia'])]); $this->_dispatchWithEmprunteurAndAssertContentEquals( - $this->_prepareEmprunteurHolding($exemplaire, 'Valensole'), - 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document \'Arcadia\' sera disponible pour être retiré à : Valensole'); + $this->_prepareEmprunteurHolding($exemplaire, 'Valensole'), + 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document \'Arcadia\' sera disponible pour être retiré à : Valensole'); } /** @test */ public function withoutMatchingHoldMessageShouldContainsDocumentNotFound() { $this->_dispatchWithEmprunteurAndAssertContentEquals( - $this->_prepareEmprunteurHolding(null, 'Valensole'), - 'Document introuvable'); + $this->_prepareEmprunteurHolding(null, 'Valensole'), + 'Document introuvable'); } /** @test */ public function withMatchingHoldAndNoPickupLocationShouldNotContainsPickupLocation() { - $this->_dispatchWithEmprunteurAndAssertContentEquals( - $this->_prepareEmprunteurHolding($this->fixture('Class_Exemplaire', ['id' => 456]), - null), - 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document sera disponible'); + $this->_dispatchWithEmprunteurAndAssertContentEquals($this->_prepareEmprunteurHolding($this->fixture(Class_Exemplaire::class, + ['id' => 456]), + null), + 'Votre réservation est enregistrée.<br>Nous vous informerons quand le document sera disponible'); } @@ -578,7 +578,8 @@ class RechercheControllerReservationWithWebServiceKohaTest public function popupResultContentWithWebServiceErrorShouldContainsErreurDeCommunication() { $this->jajm->setIdabon(395749); - $this->_prepareEmprunteurHolding($this->fixture('Class_Exemplaire', ['id' => 456]), + $this->_prepareEmprunteurHolding($this->fixture(Class_Exemplaire::class, + ['id' => 456]), 'Valensole'); $this->koha->whenCalled('isConnected')->answers(false); @@ -588,7 +589,8 @@ class RechercheControllerReservationWithWebServiceKohaTest /** @test */ public function withoutIdAbonpopupResultContentShouldContainsVousDevezVousConnecterSousVotreNumeroDeCarte() { - $this->_prepareEmprunteurHolding($this->fixture('Class_Exemplaire', ['id' => 456]), + $this->_prepareEmprunteurHolding($this->fixture(Class_Exemplaire::class, + ['id' => 456]), 'Valensole'); $this->jajm->setIdabon(null)->save(); $this->dispatchAndCheckContentEquals("Vous devez vous connecter sous votre numéro de carte pour effectuer une réservation."); @@ -600,36 +602,36 @@ class RechercheControllerReservationWithWebServiceKohaTest class RechercheControllerReservationSerialWithWebServiceKohaTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; + protected $_exemplaire; public function setUp() { parent::setUp(); $webservice = 'http://bib.valensol.net'; - $bib = $this->fixture('Class_IntBib', + $bib = $this->fixture(Class_IntBib::class, ['id' => 1, 'comm_sigb' => Class_IntBib::COM_KOHA_LEGACY, 'comm_params' => ['url_serveur' => $webservice]]); - $data_profile = $this->fixture('Class_IntProfilDonnees', - ['id' => 433, - 'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_KOHA] + $data_profile = $this->fixture(Class_IntProfilDonnees::class, + ['id' => 433, + 'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_KOHA] ); - $this->_exemplaire = $this->fixture('Class_Exemplaire', - ['id' => 203609, - 'code_barres' => 1644067, - 'id_int_bib' => 1, - 'id_origine' => '259517-123', - 'data_profile' => $data_profile, - 'notice' => $this->fixture('Class_Notice', - ['id' => 205227, - 'titre_principal' => 'Animan 210', - 'type_doc' => Class_TypeDoc::PERIODIQUE - ])]); - - $this->jajm = $this->fixture('Class_Users', + $this->_exemplaire = $this->fixture(Class_Exemplaire::class, + ['id' => 203609, + 'code_barres' => 1644067, + 'id_int_bib' => 1, + 'id_origine' => '259517-123', + 'data_profile' => $data_profile, + 'notice' => $this->fixture(Class_Notice::class, + ['id' => 205227, + 'titre_principal' => 'Animan 210', + 'type_doc' => Class_TypeDoc::PERIODIQUE + ])]); + + $this->jajm = $this->fixture(Class_Users::class, ['id' => 1, 'login' => 'jajm', 'password' => 'secret', @@ -652,8 +654,7 @@ class RechercheControllerReservationSerialWithWebServiceKohaTest protected function dispatchAndCheckContentEquals($expected) { - $this->dispatch('/recherche/reservationajax/id/205227-123/id_notice/205227-210/id_bib/1/copy_id/203609/code_annexe/VS', - true); + $this->dispatch('/recherche/reservationajax/id/205227-123/id_notice/205227-210/id_bib/1/copy_id/203609/code_annexe/VS'); $this->json = json_decode($this->_response->getBody()); $this->assertEquals($expected, $this->json->content); } @@ -694,8 +695,8 @@ class RechercheControllerReservationSerialWithWebServiceKohaTest protected function _dispatchWithEmprunteurAndAssertContentEquals($emprunteur, $content) { $this->koha ->whenCalledDefaultAnswers('reserverExemplaire',['statut' => true, - 'erreur' => '', - 'popup' => false]) + 'erreur' => '', + 'popup' => false]) ->whenCalledDefaultAnswers('getEmprunteur', $emprunteur); @@ -707,35 +708,35 @@ class RechercheControllerReservationSerialWithWebServiceKohaTest class RechercheControllerReservationCalendarAjaxTest extends AbstractControllerTestCase { + protected - $_storm_default_to_volatile = true, $_json, $_xpath; public function setUp() { parent::setUp(); - $item = $this->fixture('Class_Exemplaire', + $item = $this->fixture(Class_Exemplaire::class, ['id' => 456, 'id_origine' => 1, 'annexe' => 'VS']); $comm_sigb = (new Class_Testing_WebService_SIGB_Koha_Service()) ->whenCalledAnswers('holdsForItem', - [$item], - ['statut' => true, - 'holds' => [(new Class_WebService_SIGB_Koha_Reservation(3,$item)) - ->setReserveDate('2020-01-15') - ->setExpirationDate('2020-06-16'), - (new Class_WebService_SIGB_Koha_Reservation(2,$item)) - ->setReserveDate('2019-07-26') - ->setExpirationDate('2019-12-31')]]); + [$item], + ['statut' => true, + 'holds' => [(new Class_WebService_SIGB_Koha_Reservation(3,$item)) + ->setReserveDate('2020-01-15') + ->setExpirationDate('2020-06-16'), + (new Class_WebService_SIGB_Koha_Reservation(2,$item)) + ->setReserveDate('2019-07-26') + ->setExpirationDate('2019-12-31')]]); Class_CommSigb::setInstance($comm_sigb); - $this->dispatch('/recherche/reservation-calendar-ajax/id_bib/1/copy_id/456/code_annexe/VS',true); + $this->dispatch('/recherche/reservation-calendar-ajax/id_bib/1/copy_id/456/code_annexe/VS'); $this->_json = json_decode($this->_response->getBody()); - $this->_xpath = new Storm_Test_XPath(); + $this->_xpath = new Storm_Test_XPath; } @@ -743,7 +744,7 @@ class RechercheControllerReservationCalendarAjaxTest extends AbstractControllerT public function popupHoldsListShouldContainsDu26JuilletAu31Decembre() { $this->_xpath->assertXPathContentContains($this->_json->content, '//ul/li[1]', - utf8_encode('Du 26 juillet 2019 au 31 décembre 2019')); + Class_CharSet::fromISOtoUTF8('Du 26 juillet 2019 au 31 décembre 2019')); } @@ -751,7 +752,7 @@ class RechercheControllerReservationCalendarAjaxTest extends AbstractControllerT public function popupHoldsListShouldContainsDu15JanvierAu16Juin() { $this->_xpath->assertXPathContentContains($this->_json->content, '//ul/li[2]', - utf8_encode('Du 15 janvier 2020 au 16 juin 2020')); + Class_CharSet::fromISOtoUTF8('Du 15 janvier 2020 au 16 juin 2020')); } @@ -794,33 +795,32 @@ class RechercheControllerReservationCalendarAjaxTest extends AbstractControllerT class RechercheControllerReservationCalendarPostTest extends AbstractControllerTestCase { - protected - $_storm_default_to_volatile = true, - $_comm_sigb; + + protected $_comm_sigb; public function setUp() { parent::setUp(); + $int_bib = $this - ->fixture('Class_IntBib', + ->fixture(Class_IntBib::class, ['id' => 1, 'comm_sigb' => Class_IntBib::COM_KOHA_LEGACY, 'use_card_number' => 12345, 'comm_params' => ['bundled_holds_minimal_duration' => 29, 'url_serveur' => 'http://bib.valensol.net/cgi-bin/koha/ilsdi.pl']]); - $item = $this->fixture('Class_Exemplaire', + $item = $this->fixture(Class_Exemplaire::class, ['id' => 456, 'code_barres' => 123, 'id_int_bib' => 1, - 'notice' => $this->fixture('Class_Notice', + 'notice' => $this->fixture(Class_Notice::class, ['id' => 8890, 'titre_principal' => 'Elementaire mon cher polar', 'auteur_principal' => 'Conan Doyle'])]); - $this->_comm_sigb = (new Class_Testing_CommSigb()) - ->whenCalledAnswers('holdsForItem',[$item],['statut' => true, - 'holds' => []]); - + $this->_comm_sigb = (new Class_Testing_CommSigb) + ->whenCalledAnswers('holdsForItem', [$item], ['statut' => true, + 'holds' => []]); Class_CommSigb::setInstance($this->_comm_sigb); } @@ -833,7 +833,6 @@ class RechercheControllerReservationCalendarPostTest extends AbstractControllerT ->whenCalledDo('holdCalendar', [456,'VS','2020-01-19','2020-05-25'],fn() => []); - $this->postDispatch('/recherche/reservation-calendar-ajax/id_bib/1/copy_id/456/code_annexe/VS', ['reservedate' => '19/01/2020' , 'expirationdate' => '25/05/2020']); @@ -852,7 +851,7 @@ class RechercheControllerReservationCalendarPostTest extends AbstractControllerT 'expirationdate' => '25/05/2020']); $this->json = json_decode($this->_response->getBody()); - $xpath = new Storm_Test_XPath(); + $xpath = new Storm_Test_XPath; $xpath->assertXPathContentContains($this->json->content, '//ul[@class="errors"]/li', @@ -863,9 +862,6 @@ class RechercheControllerReservationCalendarPostTest extends AbstractControllerT /** @test */ public function withDurationInferiorToMinimunShouldDisplayErrorDurationTooSmall() { - // $this->_comm_sigb->whenCalledDo('holdCalendar', - // [456,'VS','2020-05-10','2020-05-25'], - // fn()=> $this->addError('); Class_Users::getIdentity()->setIdIntBib(1)->save(); $this->postDispatch('/recherche/reservation-calendar-ajax/id_bib/1/copy_id/456/code_annexe/VS', ['reservedate' => '10/05/2020' , @@ -890,16 +886,15 @@ class RechercheControllerReservationCalendarPostTest extends AbstractControllerT class RechercheControllerReservationWithMailFormTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - public function setUp() { parent::setUp(); - $this->fixture('Class_Bib', ['id' => 88, - 'libelle' => 'My Library', - 'mail' => 'my@library.com']); + $this->fixture(Class_Bib::class, + ['id' => 88, + 'libelle' => 'My Library', + 'mail' => 'my@library.com']); - $this->fixture('Class_Notice', + $this->fixture(Class_Notice::class, ['id' => 550171, 'type_doc' => 1, 'titre_principal' => 'Test record', @@ -907,7 +902,7 @@ class RechercheControllerReservationWithMailFormTest 'editeur' => 'Test editor', ]); - $this->dispatch('/recherche/reservation/id/550171/id_int_bib/88/id_bib/88/id_notice/550171/cote/P+TRA', true); + $this->dispatch('/recherche/reservation/id/550171/id_int_bib/88/id_bib/88/id_notice/550171/cote/P+TRA'); } @@ -946,16 +941,16 @@ class RechercheControllerReservationWithMailFormTest abstract class RechercheControllerReservationWithMailFormPostTestCase extends AbstractControllerTestCase { - protected - $_storm_default_to_volatile = true, - $_mail_transport; + + protected $_mail_transport; public function setUp() { parent::setUp(); - $this->fixture('Class_Bib', ['id' => 88, - 'libelle' => 'My Library', - 'mail' => 'my@library.com']); + $this->fixture(Class_Bib::class, + ['id' => 88, + 'libelle' => 'My Library', + 'mail' => 'my@library.com']); $unimarc = (new Class_NoticeUnimarc_Fluent) ->zoneWithContent('001', '') @@ -972,7 +967,7 @@ abstract class RechercheControllerReservationWithMailFormPostTestCase $_SESSION['captcha_code'] = 'e2df0'; - Zend_Mail::setDefaultTransport($this->_mail_transport = new MockMailTransport()); + Zend_Mail::setDefaultTransport($this->_mail_transport = new MockMailTransport); } @@ -1123,6 +1118,7 @@ class RechercheControllerReservationWithMailFormValidPostTest + abstract class RechercheControllerReservationPickupAjaxWithNanookPickupLocationsTestCase extends RechercheControllerReservationTestCase{ @@ -1130,12 +1126,12 @@ abstract class RechercheControllerReservationPickupAjaxWithNanookPickupLocations parent::setUp(); $bib = $this - ->fixture('Class_IntBib', + ->fixture(Class_IntBib::class, ['id' => 12, 'comm_sigb' => Class_IntBib::COM_NANOOK, 'comm_params' => ['url_serveur' => 'http://bib.valensol.net']]); - $this->jajm = $this->fixture('Class_Users', + $this->jajm = $this->fixture(Class_Users::class, ['id' => 1, 'login' => 'jajm', 'password' => 'secret', @@ -1159,7 +1155,8 @@ abstract class RechercheControllerReservationPickupAjaxWithNanookPickupLocations ZendAfi_Auth::getInstance()->logUser($this->jajm); - $this->fixture('Class_Exemplaire', ['id' => 12]); + $this->fixture(Class_Exemplaire::class, + ['id' => 12]); } @@ -1192,7 +1189,7 @@ class RechercheControllerReservationPickupAjaxNanookPickupLocationsPrecheckPatro ->whenCalled('reserverExemplaire')->answers(['status' => true, 'erreur' => '']); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=37©_id=12', true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=37©_id=12'); $this->_json = json_decode($this->_response->getBody()); } @@ -1216,7 +1213,7 @@ class RechercheControllerReservationPickupAjaxNanookPickupLocationsPrecheckReque $this->nanook->whenCalled('getUserAnnexe')->answers('66'); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=37©_id=12', true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=37©_id=12'); $this->_json = json_decode($this->_response->getBody()); } @@ -1240,15 +1237,15 @@ class RechercheControllerReservationPickupAjaxNanookPickupLocationsNoPrecheckTes $this->nanook->whenCalled('getUserAnnexe')->answers('66'); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=77©_id=12', true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=77©_id=12'); $this->_json = json_decode($this->_response->getBody()); } /** - * @test - * @see https://forge.afi-sa.net/issues/128814 + * @test + * @see https://forge.afi-sa.net/issues/128814 */ public function noSiteShouldBePreChecked() { $this->_xpath @@ -1267,16 +1264,16 @@ class RechercheControllerReservationPickupAjaxNanookPickupLocationsStrongInLabel $this->nanook->whenCalled('getUserAnnexe')->answers('66'); - $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=99©_id=12', true); + $this->dispatch('recherche/reservation-pickup-ajax?id_bib=2&id_origine=12&code_annexe=99©_id=12'); $this->_json = json_decode($this->_response->getBody()); } /** - @see https://forge.afi-sa.net/issues/94332 - @test - */ + * @see https://forge.afi-sa.net/issues/94332 + * @test + */ public function LunelShouldContainStrong() { $this->_xpath ->assertXPath($this->_json->content, '//strong',$this->_json->content); @@ -1363,10 +1360,10 @@ abstract class RechercheControllerReservationPickupAjaxAndNotifyByMailEnabledTes 'type_doc' => Class_TypeDoc::LIVRE]) ]); - $mock_transport = new MockMailTransport(); + $mock_transport = new MockMailTransport; Zend_Mail::setDefaultTransport($mock_transport); - $this->dispatch('recherche/reservationajax/id/11760/id_int_bib/23/id_bib/23/id_origine/594105/code_annexe/23/render/popup/copy_id/12', true); + $this->dispatch('recherche/reservationajax/id/11760/id_int_bib/23/id_bib/23/id_origine/594105/code_annexe/23/render/popup/copy_id/12'); $this->_sent_mails = $mock_transport->getSentMails(); } @@ -1520,7 +1517,7 @@ PRET_VALISE", 'id_bib' => 1, 'type' => 5]; - $bib = $this->fixture('Class_IntBib', + $bib = $this->fixture(Class_IntBib::class, ['id' => 1, 'comm_sigb' => Class_IntBib::COM_KOHA_LEGACY, 'comm_params' => $koha_service_params]); @@ -1530,7 +1527,6 @@ PRET_VALISE", ->with('http://bib.valensol.net?service=GetRecords&id=678') ->answers(KohaFixtures::getRecordsWithGroupHoldsItypes()); - Class_WebService_SIGB_KohaLegacy::getService($koha_service_params) ->setWebClient($http_client); @@ -1563,7 +1559,7 @@ PRET_VALISE", Class_CosmoVar::setValueOf('site_retrait_resa', 1); - $user = $this->fixture('Class_Users', + $user = $this->fixture(Class_Users::class, ['id' => 1, 'login' => 'jajm', 'password' => 'secret', @@ -1571,7 +1567,8 @@ PRET_VALISE", 'id_site' => 3, 'idabon' => '395749' ]); - $this->_xpath = new Storm_Test_XPath(); + + $this->_xpath = new Storm_Test_XPath; ZendAfi_Auth::getInstance()->logUser($user); } @@ -1582,13 +1579,13 @@ PRET_VALISE", $emprunteur->setLibraryCode('VS'); Class_CommSigb::setInstance(( new Class_Testing_CommSigb) ->whenCalledAnswers('ficheAbonne',[] - ,['fiche' => $emprunteur])); + ,['fiche' => $emprunteur])); $this->dispatch('/recherche/reservation-pickup-ajax/id_bib/1/copy_id/456/code_annexe/AN'); $json = json_decode($this->_response->getBody()); $this->_xpath - ->assertXPath($json->content, '//input[@type="radio"][@name="code_annexe"][ @value="VS"][ @checked="checked"]', $json->content); + ->assertXPath($json->content, '//input[@type="radio"][@name="code_annexe"][ @value="VS"][ @checked="checked"]', $json->content); } diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index dfcea7c7018a2578db68f60a9af87db3ede7e2ed..21b96f8d57f0d94cffab3b672c6c0d89d8bd9279 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -42,7 +42,7 @@ abstract class RechercheControllerNoticeTestCase extends AbstractControllerTestC ['id' => 1, 'libelle' => 'spectacle']); - $this->fixture(Class_CodifTags::class, + $this->fixture(Class_TagNotice::class, ['id' => 3, 'libelle' => 'enfants']); diff --git a/tests/library/Class/CatalogueTest.php b/tests/library/Class/CatalogueTest.php index bae3a8ad303b5f9336241683ef072ea20fd41e5a..81dbab54863654a21e6841e51e85211313fce907 100644 --- a/tests/library/Class/CatalogueTest.php +++ b/tests/library/Class/CatalogueTest.php @@ -669,7 +669,7 @@ class CatalogueBuildCriteresRechercheTest extends CatalogueTestCase { /** @test */ public function politiqueShouldHaveCritereTypeDocAsFiltre() { $this->_fetchRequestsBy(['id_catalogue' => $this->_politique->getId()]); - $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M888 F_M21860)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); + $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M21860 F_M888)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); } @@ -677,7 +677,7 @@ class CatalogueBuildCriteresRechercheTest extends CatalogueTestCase { public function politiqueShouldHaveCriterePcdm4AsFiltre() { $this->_politique->setPcdm4('45;48'); $this->_fetchRequestsBy(['id_catalogue' => $this->_politique->getId()]); - $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M888 F_M21860) +(F_P45* F_P48*)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); + $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M21860 F_M888) +(F_P45* F_P48*)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); } @@ -686,7 +686,7 @@ class CatalogueBuildCriteresRechercheTest extends CatalogueTestCase { $this->_politique->setPcdm4(''); $this->_politique->setDewey('333;222'); $this->_fetchRequestsBy(['id_catalogue' => $this->_politique->getId()]); - $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M888 F_M21860) +(F_D333* F_D222*)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); + $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M21860 F_M888) +(F_D333* F_D222*)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); } @@ -695,7 +695,7 @@ class CatalogueBuildCriteresRechercheTest extends CatalogueTestCase { $this->_politique->setDewey(''); $this->_politique->setAuteur('321;234'); $this->_fetchRequestsBy(['id_catalogue' => $this->_politique->getId()]); - $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_A321 F_A234) +(F_M21859 F_M888 F_M21860)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); + $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_A321 F_A234) +(F_M21859 F_M21860 F_M888)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); } @@ -706,7 +706,7 @@ class CatalogueBuildCriteresRechercheTest extends CatalogueTestCase { $this->_politique->setInteret('99;23'); $this->_politique->setTags('111'); $this->_fetchRequestsBy(['id_catalogue' => $this->_politique->getId()]); - $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +F_Z111 +(F_F99 F_F23) +(F_M21859 F_M888 F_M21860)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); + $this->assertSql("SELECT `notices`.* FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +F_Z111 +(F_F99 F_F23) +(F_M21859 F_M21860 F_M888)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); } @@ -716,7 +716,7 @@ class CatalogueBuildCriteresRechercheTest extends CatalogueTestCase { $this->_politique->setCoteFin('Z888.22'); $this->_politique->setTags(''); $this->_fetchRequestsBy(['id_catalogue' => $this->_politique->getId()]); - $this->assertSql("SELECT `notices`.* FROM `notices` WHERE ((`notices`.`cote` >= 'R233.48' AND `notices`.`cote` <= 'Z888.22' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M888 F_M21860)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); + $this->assertSql("SELECT `notices`.* FROM `notices` WHERE ((`notices`.`cote` >= 'R233.48' AND `notices`.`cote` <= 'Z888.22' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T1 F_T4) +(F_M21859 F_M21860 F_M888)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5000"); } } @@ -953,14 +953,14 @@ class CatalogueGetAllNoticesIdsForDomaineTest extends ModelTestCase { /** @test */ public function queryWithNb5Page10() { $this->_catalogue->getAllNoticeIdsForDomaine(5, 10); - $this->assertSql("SELECT `notices`.`id_notice` FROM `notices` WHERE ((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('F_Q3' IN BOOLEAN MODE) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_T1' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5 OFFSET 50"); + $this->assertSql("SELECT `notices`.`id_notice` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+((+F_T1) F_Q3)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 5 OFFSET 50"); } /** @test */ public function queryWithNb1Page2() { $this->_catalogue->getAllNoticeIdsForDomaine(1, 2); - $this->assertSql("SELECT `notices`.`id_notice` FROM `notices` WHERE ((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('F_Q3' IN BOOLEAN MODE) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_T1' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 1 OFFSET 2"); + $this->assertSql("SELECT `notices`.`id_notice` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+((+F_T1) F_Q3)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC LIMIT 1 OFFSET 2"); } } diff --git a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php index 747192d308f42608df228e1246113b2ca7e2f1f2..59943d34f06ae824ec02e81c29a5719dd51b5243 100644 --- a/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php +++ b/tests/library/Class/Cosmogramme/Integration/PhasePrepareIntegrationsTest.php @@ -853,7 +853,7 @@ class PhasePrepareIntegrationsFlushBeforeFullAndTotalRecordsTest protected function _prepareFixtures() { parent::_prepareFixtures(); - $this->fixture(Class_CodifTags::class, + $this->fixture(Class_TagNotice::class, ['id' => 1]); $this->fixture(Class_Notice_SerialArticles::class, @@ -919,7 +919,7 @@ class PhasePrepareIntegrationsFlushBeforeFullAndTotalRecordsTest /** @test */ public function shouldDeleteAllCodifTags() { - $this->assertEmpty(Class_CodifTags::findAll()); + $this->assertEmpty(Class_TagNotice::findAll()); } diff --git a/tests/library/Class/MoteurRechercheTest.php b/tests/library/Class/MoteurRechercheTest.php index 761defeaf827ad5d980efb4b5a9de0165b16ff1a..c76c6ba5b8e8cf4c98343dc21c02869d51d49c91 100644 --- a/tests/library/Class/MoteurRechercheTest.php +++ b/tests/library/Class/MoteurRechercheTest.php @@ -150,7 +150,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titre'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`auteurs` LIKE 'P_CLASTRES%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_YTUN F_YTAP) +F_YMED1' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`auteurs` LIKE 'P_CLASTRES%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_YMED1 F_YTUN F_YTAP)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], [['rech_matieres' => 'Philosophie', 'operateur_matieres' => 'and not', @@ -195,7 +195,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titre'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`auteurs` LIKE 'P_STIEGLER%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_G23 +F_A345 +(F_YTUN F_YTAP) +(F_S1 F_S12 F_S9) +(F_B3 F_B4) +F_YMED1' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`auteurs` LIKE 'P_STIEGLER%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_G23 +F_A345 +(F_YMED1 F_YTUN F_YTAP) +(F_S1 F_S12 F_S9) +(F_B3 F_B4)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], [['rech_titres' => 'Les décisions absurdes', 'operateur_auteurs' => 'and', @@ -207,7 +207,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titre'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`titres` LIKE 'P_LES P_DECISIONS P_ABSURDES%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_M4669 +(F_YTUN F_YTAP) +(F_B3 F_B4) +F_S1 +F_YMED1' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`titres` LIKE 'P_LES P_DECISIONS P_ABSURDES%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_M4669 +F_S1 +(F_YMED1 F_YTUN F_YTAP) +(F_B3 F_B4)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], [['rech_auteurs' => 'Stiegler', 'operateur_auteurs' => 'and', @@ -220,7 +220,7 @@ class MoteurRechercheAvanceeTest extends MoteurRechercheTestCase { 'type_recherche' => 'commence', 'pertinence' => true, 'tri' => 'alpha_titre'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`auteurs` LIKE 'P_STIEGLER%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_G23 +F_A345 +(F_T1 F_Tbokeh_page) +(F_YTUN F_YTAP) +(F_S1 F_S12 F_S9) +F_B3 +F_YMED1' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`auteurs` LIKE 'P_STIEGLER%' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_G23 +F_A345 +(F_YMED1 F_YTUN F_YTAP) +(F_T1 F_Tbokeh_page) +(F_S1 F_S12 F_S9) +F_B3' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], [['rech_titres' => 'parquets', 'operateur_titres' => 'and'], @@ -318,7 +318,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'selection_annexe' => 'TUN;TAP', 'tri' => 'alpha_titre', 'no_extension' => '1'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS) +(F_YTUN F_YTAP) +F_YMED1' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(COMMUNE COMMUNES KOMUN) +(PARI PARIS) +(F_YMED1 F_YTUN F_YTAP)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`alpha_titre` ASC"], [['expressionRecherche' => '2-7427-3315-9', 'geo_zone' => 2, @@ -353,7 +353,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'selection_annexe' => 'TUN;TAP', 'selection_sections' => '1;12;9', 'no_extension' => '1'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(LOGO LOGOS) +F_M52291 +F_A15067 +(F_YTUN F_YTAP) +(F_S1 F_S12 F_S9) +F_YMED1' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY MATCH(`notices`.`auteurs`) AGAINST('P_LOGO') DESC, MATCH(`notices`.`titres`) AGAINST('P_LOGO') DESC, MATCH(`notices`.`titres`) AGAINST('LOGO') DESC, MATCH(`notices`.`auteurs`) AGAINST('LOGO') DESC, `notices`.`date_creation` DESC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(LOGO LOGOS) +F_M52291 +F_A15067 +(F_YMED1 F_YTUN F_YTAP) +(F_S1 F_S12 F_S9)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY MATCH(`notices`.`auteurs`) AGAINST('P_LOGO') DESC, MATCH(`notices`.`titres`) AGAINST('P_LOGO') DESC, MATCH(`notices`.`titres`) AGAINST('LOGO') DESC, MATCH(`notices`.`auteurs`) AGAINST('LOGO') DESC, `notices`.`date_creation` DESC"], [['expressionRecherche' => 'logo', 'multifacets' => 'Tper_title', @@ -369,7 +369,7 @@ class MoteurRechercheSimpleTest extends MoteurRechercheTestCase { 'type_doc' => 'delete("*"),1,uraiets,2', 'selection_sections' => '1;goup<ip;9', 'no_extension' => '1'], - 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(SECURITY SECURITYS SEKURITI) +F_Y8 +(F_S1 F_S9) +F_E34 +F_B12 +(F_T1 F_Turaiets F_T2)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY MATCH(`notices`.`auteurs`) AGAINST('P_SECURITY') DESC, MATCH(`notices`.`titres`) AGAINST('P_SECURITY') DESC, MATCH(`notices`.`titres`) AGAINST('SECURITY') DESC, MATCH(`notices`.`auteurs`) AGAINST('SECURITY') DESC, `notices`.`date_creation` DESC"], + 'sql' => "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(SECURITY SECURITYS SEKURITI) +(F_T1 F_Turaiets F_T2) +F_Y8 +(F_S1 F_S9) +F_E34 +F_B12' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY MATCH(`notices`.`auteurs`) AGAINST('P_SECURITY') DESC, MATCH(`notices`.`titres`) AGAINST('P_SECURITY') DESC, MATCH(`notices`.`titres`) AGAINST('SECURITY') DESC, MATCH(`notices`.`auteurs`) AGAINST('SECURITY') DESC, `notices`.`date_creation` DESC"], [['expressionRecherche' => '', 'digital_lib' => '1'], @@ -772,7 +772,7 @@ class MoteurRechercheCatalogueTest extends MoteurRechercheTestCase { ->lancerRecherche($criteres_recherche); $this->assertSqlEquals(['SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = \'Nouveauté par annexe\' AND `codif_thesaurus`.`id_thesaurus` LIKE \'NANA%\') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1', - "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (((`notices`.`date_creation` >= '2012-05-03' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_G26 F_G25) +(F_YANNECY F_YSEYNOD) +(F_HNANA0001 F_HNANA0002)' IN BOOLEAN MODE)) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_HNANA0001 F_HNANA0002) +F_F565' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC"]); + "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`date_creation` >= '2012-05-03' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_HNANA0001 F_HNANA0002) +F_F565 +(F_G26 F_G25) +(F_YANNECY F_YSEYNOD)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC"]); $this->assertEquals(['HNANA0001', 'HNANA0002', 'F565'], $criteres_recherche->getMultiFacets()); } @@ -835,7 +835,7 @@ class MoteurRechercheWithCatalogueTest extends MoteurRechercheWithCatalogueTestC (new Class_MoteurRecherche) ->lancerRecherche((new Class_CriteresRecherche)->setParams(['id_catalogue' => 5])); - $this->assertSql("SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('F_Q5' IN BOOLEAN MODE) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_Y2 F_Y4 F_Y1)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC"); + $this->assertSql("SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+((+(F_Y2 F_Y4 F_Y1)) F_Q5)' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC"); } } @@ -883,7 +883,7 @@ class MoteurRechercheWithCatalogueAndParamsTest (new Class_MoteurRecherche)->lancerRecherche($criteres_recherche); $this->assertSqlEquals(["UPDATE `notices` SET `facettes` = CLEAN_SPACES(REGEXP_REPLACE(`facettes`, '\\\\bHCCCC0001\\\\b', '')), `facets` = CLEAN_SPACES(REGEXP_REPLACE(`facets`, '\\\\bF_HCCCC0001\\\\b', '')) WHERE (`notices`.`type_doc` NOT IN (8, 9, 10) AND `notices`.`type` = 1 AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_HCCCC0001' IN BOOLEAN MODE))", - 'SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((((`notices`.`date_creation` >= \'2014-12-23\' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+(F_T1 F_T4)\' IN BOOLEAN MODE)) OR MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'F_Q5\' IN BOOLEAN MODE)) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+F_P4* +(F_Y2 F_Y4 F_Y1)\' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`date_creation` DESC']); + 'SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`date_creation` >= \'2014-12-23\' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+((+F_P4* +(F_Y2 F_Y4 F_Y1) +(F_T1 F_T4)) F_Q5)\' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`date_creation` DESC']); } } @@ -914,7 +914,7 @@ class MoteurRechercheWithCatalogueAndUrlParamsTest (new Class_MoteurRecherche)->lancerRecherche($criteres_recherche); - $this->assertSql('SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+(F_T1 F_T4)\' IN BOOLEAN MODE) OR MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'F_Q5\' IN BOOLEAN MODE)) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+F_T1 +F_T10 +F_T5\' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC'); + $this->assertSql('SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+((+F_T1 +F_T10 +F_T5 +(F_T1 F_T4)) F_Q5)\' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC'); } } @@ -948,11 +948,11 @@ class MoteurRechercheWithCatalogueWithNoSettingsAndUrlParamsTest /** @test */ public function requestShouldUseProfilSettings() { $criteres_recherche = (new Class_CriteresRecherche)->setParams(['id_catalogue' => 5, - 'facettes' =>'T4-T8']); + 'facettes' => 'T4-T8']); (new Class_MoteurRecherche)->lancerRecherche($criteres_recherche); - $this->assertSql('SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'F_Q5\' IN BOOLEAN MODE) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+F_T4 +F_T8\' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC'); + $this->assertSql('SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST(\'+((+F_T4 +F_T8) F_Q5)\' IN BOOLEAN MODE) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC'); } } @@ -1011,7 +1011,7 @@ class MoteurRechercheExtendingTest extends MoteurRechercheTestCase { ->setParams(['axes' => 'a10renard+poisson', 'titre' => 'Recherche+avancée'])); - $this->assertSqlEquals(["SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('(+(RENARD RENARDS RENAR) +(POISSON POISSONS POISON))' IN BOOLEAN MODE) AND `notices`.`type` = 1)", + $this->assertSqlEquals(["SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('+(RENARD RENARDS RENAR) +(POISSON POISSONS POISON)' IN BOOLEAN MODE) AND `notices`.`type` = 1)", "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('RENARD RENARDS RENAR POISSON POISSONS POISON' IN BOOLEAN MODE) AND `notices`.`type` = 1)"]); } diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php index 38fde4c98ada2ef5eb505574175a54597c7c5dfd..6bfcaef6c3ea1171faa0c8ea0505797db7b25cf6 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueTest.php @@ -752,7 +752,7 @@ class ZendAfi_View_Helper_Accueil_KiosqueWithLinkedRecordsInDomainSetTest /** @test */ public function requestShouldBeAsExpected() { - $this->assertSql("SELECT `notices`.`id_notice` FROM `notices` WHERE (((`notices`.`url_vignette` > '' AND `notices`.`url_vignette` != 'NO') AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('F_Q5' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`date_creation` DESC LIMIT 50"); + $this->assertSql("SELECT `notices`.`id_notice` FROM `notices` WHERE ((`notices`.`url_vignette` > '' AND `notices`.`url_vignette` != 'NO' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('F_Q5' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`date_creation` DESC LIMIT 50"); } } diff --git a/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php b/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php index 715aeb2c08957db7f22395c3c007fbc2037c2fe3..500fc496ea238e4f8dc23990d16f6c09760b9cfd 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php +++ b/tests/library/ZendAfi/View/Helper/Notice/EnteteTest.php @@ -79,7 +79,7 @@ class ZendAfi_View_Helper_Notice_EnteteTest extends ViewHelperTestCase { $notice = $album->getNotice(); - $this->_html = $this->_helper->Notice_Entete($notice, ['entete' => Class_Codification::CHAMPS . Class_CodifTypeDoc::CODE_FACETTE]); + $this->_html = $this->_helper->Notice_Entete($notice, ['entete' => Class_Codification::CHAMPS . Class_TypeDoc::CODE_FACETTE]); } @@ -114,4 +114,4 @@ class ZendAfi_View_Helper_Notice_EnteteTest extends ViewHelperTestCase { $this->assertXPath($this->_html, '//dl/dd/a[contains(@title, "Rechercher tous les documents ayant comme Type de document: Diaporama")]', $this->_html); } -} \ No newline at end of file +} diff --git a/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php b/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php index c69d12e24c2582675a1e2b26bbb15017d8fbfb6a..dc9b9c7cd7f113df67ef9a0d2cb9496816648f4a 100644 --- a/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php +++ b/tests/library/ZendAfi/View/Helper/Notice/ExemplairesTest.php @@ -22,13 +22,14 @@ require_once 'library/ZendAfi/View/Helper/ViewHelperTestCase.php'; abstract class ZendAfi_View_Helper_Notice_ExemplairesTestCase extends ViewHelperTestCase { + protected $_html; public function setUp() { parent::setUp(); - $this->_helper = new ZendAfi_View_Helper_Notice_Exemplaires(); - $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->_helper = new ZendAfi_View_Helper_Notice_Exemplaires; + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View); } } @@ -36,17 +37,19 @@ abstract class ZendAfi_View_Helper_Notice_ExemplairesTestCase extends ViewHelper class NoticeHtmlGetExemplairesEmptyTest extends ZendAfi_View_Helper_Notice_ExemplairesTestCase { + /** @test */ function noticeHTMLShouldReturnEmptyString() { - $this->assertEquals('', $this->_helper->Notice_Exemplaires(array())); + $this->assertEquals('', $this->_helper->Notice_Exemplaires([])); } - } -class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_View_Helper_Notice_ExemplairesTestCase { +class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest + extends ZendAfi_View_Helper_Notice_ExemplairesTestCase { + public function setUp() { parent::setUp(); @@ -65,17 +68,17 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_ 'resa' => 1]]) ->beCurrentProfil(); - $exemplaires = [$this->fixture('Class_Exemplaire', + $exemplaires = [$this->fixture(Class_Exemplaire::class, [ 'id' => 10, - 'id_bib' => -1, - 'id_int_bib' => 0, - 'id_notice' => '222', - 'annexe' => 'MOUL', - 'cote' => 'DSEM', - 'is_available' => true, - 'code_barres' => "12345"]), - - $this->fixture('Class_Exemplaire', + 'id_bib' => -1, + 'id_int_bib' => 0, + 'id_notice' => '222', + 'annexe' => 'MOUL', + 'cote' => 'DSEM', + 'is_available' => true, + 'code_barres' => "12345"]), + + $this->fixture(Class_Exemplaire::class, ['id' => 11, 'id_bib' => -1, 'id_int_bib' => 0, @@ -85,7 +88,7 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_ 'is_available' => true, 'code_barres' => "12346"]), - $this->fixture('Class_Exemplaire', + $this->fixture(Class_Exemplaire::class, ['id' => 12, 'id_bib' => -1, 'id_int_bib' => 0, @@ -97,8 +100,9 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_ 'url' => 'http://www.sudoc.fr/05884144X']), ]; - $this->fixture('Class_Notice', ['id' => 222, - 'exemplaire' => $exemplaires]); + $this->fixture(Class_Notice::class, + ['id' => 222, + 'exemplaire' => $exemplaires]); $this->html = $this->_helper->Notice_Exemplaires($exemplaires, 2); } @@ -138,23 +142,23 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_ /** @test */ public function reservationLinkShouldBeRechercheReservation() { - $this->assertXPath( - $this->html, - '//a[contains(@href, "recherche/reservation/id_int_bib/0/id_bib/-1/id_notice/222/cote/DSEM")]', - $this->html); + $this->assertXPath($this->html, + '//a[contains(@href, "recherche/reservation/id_int_bib/0/id_bib/-1/id_notice/222/cote/DSEM")]'); } /** @test */ public function pageShouldContainsLinkToDisplaySameWork() { $this->assertXPath($this->html, - '//div[@class="notice_bloc_titre"][contains(@onclick, "/exemplaires-same-work/id/222")]', - $this->html); + '//div[@class="notice_bloc_titre"][contains(@onclick, "/exemplaires-same-work/id/222")]'); } + /** @test **/ public function coteShouldNotContainsSpan() { - $this->assertNotXPathContentContains($this->html, '//td', utf8_encode('DSEM<span></span>'),$this->html); + $this->assertNotXPathContentContains($this->html, + '//td', + Class_CharSet::fromISOtoUTF8('DSEM<span></span>')); } @@ -169,12 +173,15 @@ class NoticeHtmlGetExemplairesWithOneExemplaireNoWebServiceTest extends ZendAfi_ -abstract class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTestCase extends ZendAfi_View_Helper_Notice_ExemplairesTestCase { +abstract class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTestCase + extends ZendAfi_View_Helper_Notice_ExemplairesTestCase { + protected $exemplaire; protected $sigb_exemplaire; public function setUp() { parent::setUp(); + $_SESSION['id_profil'] = 4; $this->sigb_exemplaire = Class_WebService_SIGB_Exemplaire::newInstance() @@ -198,14 +205,13 @@ abstract class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTestCase ex 'resa' => 1]]) ->beCurrentProfil(); - Class_IntBib::getLoader() ->newInstanceWithId(1) ->setCommSigb(Class_IntBib::COM_MICROBIB) ->setCommParams(['url_serveur' => '']); $this->exemplaire = - $this->fixture('Class_Exemplaire', + $this->fixture(Class_Exemplaire::class, ['id' => 12, 'id_bib' => 4, 'id_int_bib' => 1, @@ -230,15 +236,21 @@ class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTest public function setUp() { parent::setUp(); + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 0]); - Class_CodifEmplacement::newInstanceWithId('2', ['libelle' => 'Etage 2']); + + $this->fixture(Class_CodifEmplacement::class, + ['id' => 2, + 'libelle' => 'Etage 2', + 'regles' => '995$9=0@@3']); + $this->html = $this->_helper->Notice_Exemplaires([$this->exemplaire]); } /** @test **/ public function emplacementShoudBeEtage2() { - $this->assertXPathContentContains($this->html,'//td[@class="emplacement"]','Etage 2',$this->html); + $this->assertXPathContentContains($this->html, '//td[@class="emplacement"]', 'Etage 2'); } @@ -251,7 +263,9 @@ class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTest /** @test **/ public function disponibiliteShoudBeDisponibleAnd4Reservations() { - $this->assertXPathContentContains($this->html, '//td', utf8_encode('Nb résas: 4')); + $this->assertXPathContentContains($this->html, + '//td', + Class_CharSet::fromISOtoUTF8('Nb résas: 4')); } @@ -259,19 +273,22 @@ class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTest public function withOutEditionCoteColonneTitleShoudBeCote() { $this->assertNotXPathContentContains($this->html, '//th', - utf8_encode('<span>(Edition)</span>')); + Class_CharSet::fromISOtoUTF8('<span>(Edition)</span>')); } } -class NoticeHtmlGetExemplairesWithOneExemplairesAndWebServiceAndEditionTest extends NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTestCase { + +class NoticeHtmlGetExemplairesWithOneExemplairesAndWebServiceAndEditionTest + extends NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTestCase { public function setup() { parent::setup(); + $this->sigb_exemplaire->setEdition('2011'); Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 0]); - $this->html = $this->_helper->Notice_Exemplaires(array($this->exemplaire)); + $this->html = $this->_helper->Notice_Exemplaires([$this->exemplaire]); } @@ -279,7 +296,7 @@ class NoticeHtmlGetExemplairesWithOneExemplairesAndWebServiceAndEditionTest exte public function coteShouldBeDSEMAnd2011() { $this->assertXPathContentContains($this->html, '//td', - utf8_encode('DSEM<span>2011</span>')); + Class_CharSet::fromISOtoUTF8('DSEM<span>2011</span>')); } @@ -287,21 +304,22 @@ class NoticeHtmlGetExemplairesWithOneExemplairesAndWebServiceAndEditionTest exte public function coteColonneTitleShouldBeCoteEdition() { $this->assertXPathContentContains($this->html, '//th', - utf8_encode('Cote<span>(Edition)</span>')); + Class_CharSet::fromISOtoUTF8('Cote<span>(Edition)</span>')); } } + class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceAndPickupActiveTest extends NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceTestCase { - public function setUp() { parent::setUp(); + Class_CosmoVar::newInstanceWithId('site_retrait_resa', ['valeur' => 1]); - $this->html = $this->_helper->Notice_Exemplaires(array($this->exemplaire)); + $this->html = $this->_helper->Notice_Exemplaires([$this->exemplaire]); } @@ -311,4 +329,4 @@ class NoticeHtmlGetExemplairesWithOneExemplaireAndWebServiceAndPickupActiveTest $this->assertXPath($this->html, '//a[@data-popup="true"][contains(@href, "recherche/reservation-pickup-ajax/id_notice/24765/id_int_bib/1/id_bib/4/copy_id/12/code_annexe/MOUL")]'); } -} \ No newline at end of file +} diff --git a/tests/scenarios/AdvancedSearch/AdvancedSearchResultTest.php b/tests/scenarios/AdvancedSearch/AdvancedSearchResultTest.php index 15e54476e008321fa063029bd4158c81555f2012..b5b68ef7623ad2870443f88eb7fa10e96a901a17 100644 --- a/tests/scenarios/AdvancedSearch/AdvancedSearchResultTest.php +++ b/tests/scenarios/AdvancedSearch/AdvancedSearchResultTest.php @@ -185,19 +185,19 @@ class AdvancedSearchResultAxesToSqlTest extends AbstractControllerTestCase { "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_HTHES0001' IN BOOLEAN MODE) OR MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_HTHES012T F_HTHES00SJ)' IN BOOLEAN MODE)) AND `notices`.`type` = 1)"], ['a10%22Jardins%22', // title with exact expression - "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('\"JARDINS\"' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], + "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('+\"JARDINS\"' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], ['a12%22bien+commun%22-12%22biens+communs%22', - "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`matieres`) AGAINST('\"BIEN COMMUN\" \"BIENS COMMUNS\"' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], + "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`matieres`) AGAINST('(+\"BIEN COMMUN\") (+\"BIENS COMMUNS\")' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], ['a10bien+commun-10oeuvre+litéraire', "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('(+(BIEN BIENS BIN) +(COMMUN COMMUNS KOMIN)) (+(OEUVRE OEUVRES EVR) +(LITERAIRE LITERAIRES LITERAIR))' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], ['a12%22bien+commun%22~a12%22biens+communs%22', - "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`matieres`) AGAINST('\"BIEN COMMUN\"' IN BOOLEAN MODE) AND MATCH(`notices`.`matieres`) AGAINST('\"BIENS COMMUNS\"' IN BOOLEAN MODE)) AND `notices`.`type` = 1)"], + "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((MATCH(`notices`.`matieres`) AGAINST('+\"BIEN COMMUN\"' IN BOOLEAN MODE) AND MATCH(`notices`.`matieres`) AGAINST('+\"BIENS COMMUNS\"' IN BOOLEAN MODE)) AND `notices`.`type` = 1)"], ['a10renard+poisson', - "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('(+(RENARD RENARDS RENAR) +(POISSON POISSONS POISON))' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], + "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('+(RENARD RENARDS RENAR) +(POISSON POISSONS POISON)' IN BOOLEAN MODE) AND `notices`.`type` = 1)"], ['a10bois-10escaliers', "SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (MATCH(`notices`.`titres`) AGAINST('BOI BOIS ESCALIER ESCALIERS ESKALI' IN BOOLEAN MODE) AND `notices`.`type` = 1)"] diff --git a/tests/scenarios/AdvancedSearch/AdvancedSearchTest.php b/tests/scenarios/AdvancedSearch/AdvancedSearchTest.php index 2aec72cce09a17f80b02540358bfddacbed3ba8c..a2230f013667f4d43c5511b32a353a6049e9f3d2 100644 --- a/tests/scenarios/AdvancedSearch/AdvancedSearchTest.php +++ b/tests/scenarios/AdvancedSearch/AdvancedSearchTest.php @@ -1349,7 +1349,7 @@ class AdvancedSearchFormWithDomainCriteriaDispatchTest extends AbstractControlle $this->fixture(Class_CodifCentreInteret::class, ['id' => 1, 'libelle' => 'eau']); - $this->fixture(Class_CodifTags::class, + $this->fixture(Class_TagNotice::class, ['id' => 1, 'libelle' => 'Nous avons aimé']); diff --git a/tests/scenarios/Catalog/CustomCatalogTest.php b/tests/scenarios/Catalog/CustomCatalogTest.php index c10b1cf0ad9096139cc83cc23121bedc9b0348a3..e5c1a375196545a760cb6ca5b66b524eaf2f95ae 100644 --- a/tests/scenarios/Catalog/CustomCatalogTest.php +++ b/tests/scenarios/Catalog/CustomCatalogTest.php @@ -667,7 +667,7 @@ class CustomCatalogSearchResultTest extends AbstractControllerTestCase { 'record_alpha_key' => 'POMME']); $this->dispatch('/recherche/simple/id_catalogue/666'); - $this->assertSql("SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE (((`notices`.`annee` >= '2023' AND `notices`.`date_creation` >= '2022-06-12' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_T19 F_T15 F_T25 F_T20 F_T21 F_T22 F_T16 F_T24 F_T28 F_TNumilog F_T41 F_T1 F_T33 F_T35 F_T2 F_T37 F_T36 F_T27 F_TArteCampus F_T26) +F_B21' IN BOOLEAN MODE) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_HETAT0001 F_HETAT0002 F_HETAT0009 F_HETAT0007)' IN BOOLEAN MODE)) OR MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('F_Q666' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC"); + $this->assertSql("SELECT `notices`.`id_notice`, `notices`.`facettes` FROM `notices` WHERE ((`notices`.`annee` >= '2023' AND `notices`.`date_creation` >= '2022-06-12' AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+((+(F_T19 F_T15 F_T25 F_T20 F_T21 F_T22 F_T16 F_T24 F_T28 F_TNumilog F_T41 F_T1 F_T33 F_T35 F_T2 F_T37 F_T36 F_T27 F_TArteCampus F_T26) +F_B21) F_Q666)' IN BOOLEAN MODE) AND MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+(F_HETAT0001 F_HETAT0002 F_HETAT0009 F_HETAT0007)' IN BOOLEAN MODE)) AND `notices`.`type` = 1) ORDER BY `notices`.`annee` DESC, `notices`.`alpha_titre` ASC"); } } diff --git a/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php b/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php index 0f9d7763cfbeb21d0f8aff679e51ec76ee1aebd5..8b7179ba71b8e224cd165d8621e42f45f1c7a51c 100644 --- a/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php +++ b/tests/scenarios/CodificationBrowser/CodificationBrowserTest.php @@ -228,7 +228,7 @@ class CodificationBrowserSubjectSimpleIndexTest extends CodificationBrowserSimpl class CodificationBrowserTagsSimpleIndexTest extends CodificationBrowserSimpleIndexTestCase { protected $_controller = 'tag-browser', - $_model = 'Class_CodifTags', + $_model = 'Class_TagNotice', $_attribs = ['id' => 45, 'libelle' => 'MySuperTag', 'a_moderer' => '']; } @@ -298,4 +298,4 @@ class CodificationBrowserFormatedLabelTest extends ModelTestCase { 'libelle' => '']); $this->assertEquals('8.88448', $pcdm4->getLibelle()); } -} \ No newline at end of file +} diff --git a/tests/scenarios/DynamicFacetOnDomains/DynamicFacetOnDomainsPhaseTest.php b/tests/scenarios/DynamicFacetOnDomains/DynamicFacetOnDomainsPhaseTest.php index 02a5b3878677ad8c3c957a6b328a0cfa1df2fe13..d1c4637df06b51fa4d5864aea9fe01b4414e223a 100644 --- a/tests/scenarios/DynamicFacetOnDomains/DynamicFacetOnDomainsPhaseTest.php +++ b/tests/scenarios/DynamicFacetOnDomains/DynamicFacetOnDomainsPhaseTest.php @@ -166,27 +166,10 @@ class DynamicFacetOnDomainsPhaseEnabledTest extends DynamicFacetOnDomainsPhaseTe /** @test */ public function allSqlUpdatesShouldBePresent() { - $this->assertSqlEquals(["SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'DOMAIN' AND `codif_thesaurus`.`rules` > '')", - - "UPDATE `notices` SET `facettes` = CLEAN_SPACES(REGEXP_REPLACE(`facettes`, '\\\\bHANIM[a-zA-Z0-9]*\\\\b', '')), `facets` = CLEAN_SPACES(REGEXP_REPLACE(`facets`, '\\\\bF_HANIM[a-zA-Z0-9]*\\\\b', '')) WHERE (MATCH(`notices`.`facets`) AGAINST('F_HANIM*' IN BOOLEAN MODE))", - - "DELETE FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`id_thesaurus` LIKE 'ANIM%' AND `codif_thesaurus`.`rules` IS null AND `codif_thesaurus`.`id_origine` NOT IN ('21', '22'))", - - "SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'DOMAIN' AND `codif_thesaurus`.`id_thesaurus` LIKE 'ANIM%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1", - - "SELECT `codif_matiere`.* FROM `codif_matiere` WHERE (`codif_matiere`.`libelle` LIKE 'Animaux de la ferme : %')", - - "UPDATE `notices` SET `facettes` = CONCAT(`facettes`, ' HANIM0001'), `facets` = CONCAT(`facets`, ' F_HANIM0001') WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_M1' IN BOOLEAN MODE) AND `notices`.`type` = 1)", - - "SELECT `codif_matiere`.* FROM `codif_matiere` WHERE (`codif_matiere`.`libelle` LIKE 'Animaux de compagnie : %')", - - "UPDATE `notices` SET `facettes` = CONCAT(`facettes`, ' HANIM0002'), `facets` = CONCAT(`facets`, ' F_HANIM0002') WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_M2' IN BOOLEAN MODE) AND `notices`.`type` = 1)", - - "UPDATE `notices` SET `facettes` = CLEAN_SPACES(REGEXP_REPLACE(`facettes`, '\\\\bHSUPP[a-zA-Z0-9]*\\\\b', '')), `facets` = CLEAN_SPACES(REGEXP_REPLACE(`facets`, '\\\\bF_HSUPP[a-zA-Z0-9]*\\\\b', '')) WHERE (MATCH(`notices`.`facets`) AGAINST('F_HSUPP*' IN BOOLEAN MODE))", - - "DELETE FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`id_thesaurus` LIKE 'SUPP%' AND `codif_thesaurus`.`rules` IS null AND `codif_thesaurus`.`id_origine` NOT IN (3, 2, 4))", - - "SELECT `codif_thesaurus`.* FROM `codif_thesaurus` WHERE (`codif_thesaurus`.`code` = 'DOMAIN' AND `codif_thesaurus`.`id_thesaurus` LIKE 'SUPP%') ORDER BY `codif_thesaurus`.`id_thesaurus` DESC LIMIT 1"]); + $this->assertSql("UPDATE `notices` SET `facettes` = CLEAN_SPACES(REGEXP_REPLACE(`facettes`, '\\\\bHANIM[a-zA-Z0-9]*\\\\b', '')), `facets` = CLEAN_SPACES(REGEXP_REPLACE(`facets`, '\\\\bF_HANIM[a-zA-Z0-9]*\\\\b', '')) WHERE (MATCH(`notices`.`facets`) AGAINST('F_HANIM*' IN BOOLEAN MODE))"); + $this->assertSql("UPDATE `notices` SET `facettes` = CONCAT(`facettes`, ' HANIM0001'), `facets` = CONCAT(`facets`, ' F_HANIM0001') WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_M1' IN BOOLEAN MODE) AND `notices`.`type` = 1)"); + $this->assertSql("UPDATE `notices` SET `facettes` = CONCAT(`facettes`, ' HANIM0002'), `facets` = CONCAT(`facets`, ' F_HANIM0002') WHERE (MATCH(`notices`.`titres`, `notices`.`auteurs`, `notices`.`editeur`, `notices`.`collection`, `notices`.`matieres`, `notices`.`dewey`, `notices`.`other_terms`, `notices`.`facets`) AGAINST('+F_M2' IN BOOLEAN MODE) AND `notices`.`type` = 1)"); + $this->assertSql("UPDATE `notices` SET `facettes` = CLEAN_SPACES(REGEXP_REPLACE(`facettes`, '\\\\bHSUPP[a-zA-Z0-9]*\\\\b', '')), `facets` = CLEAN_SPACES(REGEXP_REPLACE(`facets`, '\\\\bF_HSUPP[a-zA-Z0-9]*\\\\b', '')) WHERE (MATCH(`notices`.`facets`) AGAINST('F_HSUPP*' IN BOOLEAN MODE))"); } } diff --git a/tests/scenarios/Journal/JournalArticlesTest.php b/tests/scenarios/Journal/JournalArticlesTest.php index a98aab7b7443f186ca959b52697c031789d0412e..0bf25e1549b6184fdab5ab2636a65b96796a2923 100644 --- a/tests/scenarios/Journal/JournalArticlesTest.php +++ b/tests/scenarios/Journal/JournalArticlesTest.php @@ -19,9 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once(__DIR__ . '/JournalTest.php'); -abstract class JournalArticlesTestCase extends JournalTestCase { +abstract class JournalArticlesTestCase extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); diff --git a/tests/scenarios/Journal/JournalProfileTest.php b/tests/scenarios/Journal/JournalProfileTest.php index 00b6559a105b02b5b692e7f52d6cad26ed7c03e9..34ec74038104343b5e19335afea0e505d2c5f906 100644 --- a/tests/scenarios/Journal/JournalProfileTest.php +++ b/tests/scenarios/Journal/JournalProfileTest.php @@ -18,10 +18,9 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -require_once(__DIR__ . '/JournalTest.php'); -abstract class JournalProfileTestCase extends JournalTestCase { +abstract class JournalProfileTestCase extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); diff --git a/tests/scenarios/Journal/JournalTest.php b/tests/scenarios/Journal/JournalTest.php index e519d10816076ef6a187c12a0c4bd462df475211..4acbe90d37f26b03558c8d93c0a5858824fa9974 100644 --- a/tests/scenarios/Journal/JournalTest.php +++ b/tests/scenarios/Journal/JournalTest.php @@ -20,15 +20,7 @@ */ - -abstract class JournalTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; -} - - - - -class JournalAdminVarPostTest extends JournalTestCase { +class JournalAdminVarPostTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); Class_AdminVar::set('FACETTE_GENRE_LIBELLE', ''); @@ -82,7 +74,7 @@ class JournalAdminVarPostTest extends JournalTestCase { -class JournalAdminVarPostWithJournalDisabledTest extends JournalTestCase { +class JournalAdminVarPostWithJournalDisabledTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); Class_AdminVar::set('FACETTE_GENRE_LIBELLE', ''); @@ -104,7 +96,7 @@ class JournalAdminVarPostWithJournalDisabledTest extends JournalTestCase { -abstract class JournalWithEntriesTestCase extends JournalTestCase { +abstract class JournalWithEntriesTestCase extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -238,7 +230,7 @@ class JournalViewAdminVarSaveActionTest extends JournalWithEntriesTestCase { -class JournalWithActivityPubJournalEntriesActionTest extends JournalTestCase { +class JournalWithActivityPubJournalEntriesActionTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -271,7 +263,7 @@ class JournalWithActivityPubJournalEntriesActionTest extends JournalTestCase { -class JournalErrorsTest extends JournalTestCase { +class JournalErrorsTest extends Admin_AbstractControllerTestCase { /** * @test * @expectedException Zend_Controller_Action_Exception diff --git a/tests/scenarios/Templates/HerissonTemplateTest.php b/tests/scenarios/Templates/HerissonTemplateTest.php index 8b2254495ce27aac9e4b7ecdca460fe079a64407..0b496ee4535bc3994dce1bd11379085eab59c4a0 100644 --- a/tests/scenarios/Templates/HerissonTemplateTest.php +++ b/tests/scenarios/Templates/HerissonTemplateTest.php @@ -22,12 +22,11 @@ abstract class HerissonTemplateTestCase extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true, - $_current_profile; - + protected $_current_profile; public function setUp() { parent::setUp(); + $profile = $this->_buildTemplateProfil(['id' => 22]); $this->_addFixtures(); @@ -43,14 +42,14 @@ abstract class HerissonTemplateTestCase extends AbstractControllerTestCase { } - protected function _addFixtures() { - } + protected function _addFixtures() {} } class HerissonTemplateSubPagesTest extends HerissonTemplateTestCase { + /** @test */ public function pageAgendaShouldBeCreated() { $this->assertNotNull(Class_Profil::findFirstBy(['parent_id' => $this->_current_profile->getId(), @@ -121,23 +120,24 @@ class HerissonTemplateSubPagesTest extends HerissonTemplateTestCase { class HerissonTemplateRechercheViewNoticeHarryPotterTest extends HerissonTemplateTestCase { + public function setUp() { parent::setUp(); - $this->fixture('Class_Bib', + $this->fixture(Class_Bib::class, ['id' => 3, 'libelle' => 'Annecy', - 'lieu' => $this->fixture('Class_Lieu', + 'lieu' => $this->fixture(Class_Lieu::class, ['id' => 2, 'libelle' => 'Bonlieu', 'latitude' => 1, 'longitude' => 1])]); - $this->fixture('Class_Notice', + $this->fixture(Class_Notice::class, ['id' => 23, 'unimarc' => file_get_contents(__DIR__ . '/../../fixtures/dvd_potter.uni'), 'exemplaires' => [ - $this->fixture('Class_Exemplaire', + $this->fixture(Class_Exemplaire::class, ['id' => 2, 'id_bib' => 3]) ]]); @@ -161,9 +161,12 @@ class HerissonTemplateRechercheViewNoticeHarryPotterTest extends HerissonTemplat + class HerissonTemplateIndexTest extends HerissonTemplateTestCase { + public function setUp() { parent::setUp(); + $this->dispatch('/index'); } @@ -193,7 +196,6 @@ class HerissonTemplateIndexTest extends HerissonTemplateTestCase { class HerissonTemplateMenuEntriesDispatchTest extends HerissonTemplateTestCase { - /** @test */ public function menuAdulteShouldBeActiveWhenDispatchingAccueilAdulte() { $this->dispatch('/accueil/adulte'); @@ -271,11 +273,9 @@ class HerissonTemplateMenuEntriesDispatchTest extends HerissonTemplateTestCase { class HerissonTemplateSubProfilesRewriteUrlTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { parent::setUp(); + $profile = $this->_buildTemplateProfil(['id' => 21, 'libelle' => 'accueil', 'rewrite_url' => 'agenda']); @@ -316,11 +316,9 @@ class HerissonTemplateSubProfilesRewriteUrlTest extends AbstractControllerTestCa class HerissonTemplateLibraryRewriteUrlTest extends AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; - - public function setUp() { parent::setUp(); + $profile = $this->_buildTemplateProfil(['id' => 21, 'libelle' => 'accueil', 'rewrite_url' => 'agenda']); @@ -346,9 +344,12 @@ class HerissonTemplateLibraryRewriteUrlTest extends AbstractControllerTestCase { + class HerissonTemplateMentionsLegalesTest extends HerissonTemplateTestCase { + public function setUp() { parent::setUp(); + $profile = Class_Profil::findFirstBy(['libelle' => 'Mentions légales']); Class_Article_Loader::setSelectTool(new Class_Article_SelectForTest); $this->dispatch('/index/index/id_profil/' . $profile->getId()); @@ -388,7 +389,6 @@ class HerissonTemplateMentionsLegalesTest extends HerissonTemplateTestCase { class HerissonTemplateDispatchRechercheViewnotice extends HerissonTemplateTestCase { - public function setUp() { parent::setUp(); @@ -417,7 +417,6 @@ class HerissonTemplateDispatchRechercheViewnotice extends HerissonTemplateTestCa class HerissonTemplateWithResponseMultipleCarouselTest extends HerissonTemplateTestCase { - public function setUp() { parent::setUp(); diff --git a/tests/scenarios/Templates/TemplatesSearchFacetsTest.php b/tests/scenarios/Templates/TemplatesSearchFacetsTest.php index 41893cb42f2b7080899adfbad29a36842cb50d6d..0940a056b77a8f145a47bc1d6e8af3a603d931ea 100644 --- a/tests/scenarios/Templates/TemplatesSearchFacetsTest.php +++ b/tests/scenarios/Templates/TemplatesSearchFacetsTest.php @@ -31,19 +31,6 @@ class TemplatesSearchFacetsTest extends AbstractControllerTestCase { 'libelle' => 'Search Facets']) ->assertSave(); - $sql = $this->mock() - ->whenCalled('fetchAll') - ->with("select id_notice, facettes from notices Where (MATCH(titres, auteurs, editeur, collection, matieres, dewey, other_terms) AGAINST('+(GUILLAUME GUILLAUMES GIOM) +(MUSSO MUSSOS MUSO)' IN BOOLEAN MODE)) and type=1 order by date_creation asc, alpha_titre asc", - true, - false) - ->answers([[10, 'A1'], - [11, 'A1'], - [12, 'A2'], - [13, 'A3'], - ]); - - Zend_Registry::set('sql', $sql); - $this->fixture(Class_CodifAuteur::class, ['id' => 1, 'libelle' => 'Guillaume Musso' @@ -61,6 +48,7 @@ class TemplatesSearchFacetsTest extends AbstractControllerTestCase { ['id' => 10, 'auteurs' => 'GUILLAUME MUSSO', 'facettes' => 'A1', + 'type' => 1, 'exemplaires' => [$this->fixture(Class_Exemplaire::class, ['id' => 100, 'code_barres' => '1234'])] @@ -69,6 +57,7 @@ class TemplatesSearchFacetsTest extends AbstractControllerTestCase { ['id' => 11, 'auteurs' => 'GUILLAUME MUSSO', 'facettes' => 'A1', + 'type' => 1, 'exemplaires' => [$this->fixture(Class_Exemplaire::class, ['id' => 101, 'code_barres' => '5678'])] @@ -77,6 +66,7 @@ class TemplatesSearchFacetsTest extends AbstractControllerTestCase { ['id' => 12, 'auteurs' => 'GUILLAUME MUSSO', 'facettes' => 'A2', + 'type' => 1, 'exemplaires' => [$this->fixture(Class_Exemplaire::class, ['id' => 102, 'code_barres' => '9012'])] @@ -85,6 +75,7 @@ class TemplatesSearchFacetsTest extends AbstractControllerTestCase { ['id' => 13, 'auteurs' => 'GUILLAUME MUSSO ARNAUD ROMAIN', 'facettes' => 'A3', + 'type' => 1, 'exemplaires' => [$this->fixture(Class_Exemplaire::class, ['id' => 103, 'code_barres' => '3456'])] diff --git a/tests_db/UpgradeDBTest.php b/tests_db/UpgradeDBTest.php index 38c105e3d56d3f3d4d2c0a255f4fcdcd459598c1..6f8fffaa76803ba6ab598de4a8cfb86184f68403 100644 --- a/tests_db/UpgradeDBTest.php +++ b/tests_db/UpgradeDBTest.php @@ -5960,3 +5960,54 @@ class UpgradeDB_464_Test extends UpgradeDBTestCase $this->assertFieldType('lieux', 'zoom', 'int(3)'); } } + + + + +class UpgradeDB_465_Test extends UpgradeDBTestCase +{ + + public function prepare() + { + $this->silentQuery('ALTER TABLE `codif_matiere` DROP INDEX IF EXISTS `libelle`;'); + + $this->silentQuery("INSERT INTO `codif_tags` (`libelle`, `notices`, `a_moderer`) VALUES ('TAGS_LIBELLE_DELETE_1', ' ; 12 ; 34 ; ', ';999;');"); + + $this->silentQuery("INSERT INTO `codif_tags` (`libelle`, `notices`, `a_moderer`) VALUES ('TAGS_LIBELLE_DELETE_2', '56', ' ; 1000 ; 1001 ; ');"); + } + + + public function tearDown() + { + $this->query("DELETE FROM `codif_tags` WHERE `libelle` = 'TAGS_LIBELLE_DELETE_1';"); + + $this->query("DELETE FROM `codif_tags` WHERE `libelle` = 'TAGS_LIBELLE_DELETE_2';"); + + parent::tearDown(); + } + + + /** @test */ + public function indexLibelleMatiereShouldBeCreated() + { + $this->assertIndex('codif_matiere', 'libelle'); + } + + + /** @test */ + public function fieldNoticesAmodererOnCodifTags_1_ShouldBeUpdated() + { + $data = $this->query('SELECT `notices`, `a_moderer` FROM `codif_tags` WHERE `libelle` = "TAGS_LIBELLE_DELETE_1";')->fetch(); + $this->assertEquals('12 34', $data['notices']); + $this->assertEquals('999', $data['a_moderer']); + } + + + /** @test */ + public function fieldNoticesAmodererOnCodifTags_2_ShouldBeUpdated() + { + $data = $this->query('SELECT `notices`, `a_moderer` FROM `codif_tags` WHERE `libelle` = "TAGS_LIBELLE_DELETE_2";')->fetch(); + $this->assertEquals('56', $data['notices']); + $this->assertEquals('1000 1001', $data['a_moderer']); + } +}