diff --git a/FEATURES/82369 b/FEATURES/82369 new file mode 100644 index 0000000000000000000000000000000000000000..cc6442546f005c65703fed41b860d7f74f01bace --- /dev/null +++ b/FEATURES/82369 @@ -0,0 +1,11 @@ +'82369' => + ['Label' => $this->_('Mise en commun des paniers'), + 'Desc' => $this->_('En associant des paniers à des domaines, vous pouvez constituer ces paniers collaborativement et indiquer aux utilisateurs que les notices recherchées font partie d\'une sélection.'), + 'Image' => '', + 'Video' => 'https://youtu.be/GM4Ff3gMCuk', + 'Category' => 'Recherche', + 'Right' => function($feature_description, $user) {return true;}, + 'Wiki' => 'http://wiki.bokeh-library-portal.org/index.php?title=Paniers#Gestions_des_paniers_pour_les_professionnels', + 'Test' => '', + 'Date' => '2018-11-19'], + diff --git a/VERSIONS_WIP/82369 b/VERSIONS_WIP/82369 new file mode 100644 index 0000000000000000000000000000000000000000..dd4c9b5708498517b99babf5a09f565584a01ec2 --- /dev/null +++ b/VERSIONS_WIP/82369 @@ -0,0 +1 @@ + - ticket #82369 : correction de l'indexation des notices des paniers reliés à des domaines. Amélioration de l'ergonomie de gestion des paniers collaboratifs. \ No newline at end of file diff --git a/application/modules/admin/controllers/CatalogueController.php b/application/modules/admin/controllers/CatalogueController.php index 55427b3133708ad4a549ad2c6873d096a19201c0..59e586a3a2105f6dac1e59856eae05a101c1b91d 100644 --- a/application/modules/admin/controllers/CatalogueController.php +++ b/application/modules/admin/controllers/CatalogueController.php @@ -41,24 +41,23 @@ class Admin_CatalogueController extends ZendAfi_Controller_Action { $this->_redirect("admin/catalogue/index"); $ret = ['requete' => '', - 'temps_execution' => '', 'nb_notices' => 0, 'avec_vignettes' => 0, 'notices' => '']; - + $this->getRequest()->setParam('render', null); $ret = array_merge($ret, $catalogue->getTestCatalogue()); - $catalogue->isIndexable() - ? $catalogue->index() - : $this->view->error = $this->_('Le domaine ne ne peut pas être mis en favori utilisateur sans critères d\'indexation'); + if ($catalogue->hasIndexer()) + $catalogue->indexWithBaskets(); + + if (!$catalogue->isIndexable() && ($catalogue->numberOfPanierNotices() == 0)) + $this->view->error = $this->_('Le domaine ne peut pas être mis en favori utilisateur sans critères d\'indexation'); - $this->view->requete = $ret["requete"]; - $this->view->temps_execution = $ret["temps_execution"] . " secs."; $this->view->nb_notices = $ret["nb_notices"]; $this->view->avec_vignettes = $ret["avec_vignettes"]; $this->view->notices = $ret["notices"]; $this->view->catalogue = $catalogue; - $this->view->titre = $this->_('Test du domaine: %s', $catalogue->getLibelle()); + $this->view->titre = $this->_('Indexation du domaine: %s', $catalogue->getLibelle()); } diff --git a/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml b/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml index 23eb183b4567f8f7f81d76ffc93ea50dfa81bb65..3b16c8d1c2704ce1c84083b6ebc0b71a155476ef 100644 --- a/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml +++ b/application/modules/admin/views/scripts/catalogue/_catalogue_row.phtml @@ -9,7 +9,7 @@ $editable = $catalog->canBeDeletedOrModifyByUser($user); <div class="actions"> <?php $actions = [ - ['action' => 'tester', 'icon' => 'test', 'help' => $this->_('Tester')], + ['action' => 'tester', 'icon' => 'test', 'help' => $this->_('Indexer les notices')], ['action' => 'edit', 'icon' => 'edit', 'help' => $this->_('Modifier'), 'display' => $editable], ['action' => 'duplicate', 'icon' => 'copy', 'help' => $this->_('Dupliquer')], ['action' => 'add', 'icon' => 'add_page', 'help' => $this->_('Ajouter un sous-domaine'), 'display' => $editable], @@ -32,11 +32,11 @@ $editable = $catalog->canBeDeletedOrModifyByUser($user); echo $this->tag('a', $this->boutonIco('type=del'), ['href' => BASE_URL . '/admin/catalogue/delete/id_catalogue/'.$catalog->getId()]); - $catalogue_url = $this->absoluteUrl(['module' => 'opac', - 'controller' => 'recherche', - 'action' => 'simple', - 'id_catalogue' => $catalog->getId()], - null, true); + $catalogue_url = $this->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'id_catalogue' => $catalog->getId()], + null, true); echo $this->tagPreview($catalogue_url, $this->_('Visualiser le domaine "%s" dans un nouvel onglet', $catalog->getLibelle())); diff --git a/application/modules/admin/views/scripts/catalogue/form.phtml b/application/modules/admin/views/scripts/catalogue/form.phtml index 42effded8e2a3da4250fbf10c891c137cfc5ce2d..f1801d30b512212c3c0799d22de204a777b47e10 100644 --- a/application/modules/admin/views/scripts/catalogue/form.phtml +++ b/application/modules/admin/views/scripts/catalogue/form.phtml @@ -1,15 +1,33 @@ <?php -if(!$this->catalogue->isNew()) +if(!$this->catalogue->isNew()) { echo $this->tag('div', $this->tagAnchor($this->url(['action' => 'tester', 'id_catalogue' => $this->catalogue->getId()]), Class_Admin_Skin::current() ->renderActionIconOn('test', $this, - ['alt' => $this->_('Tester'), - 'title' => $this->_('Tester le catalogue "%s"', - $this->catalogue->getLibelle())]), - ['data-popup' => true]), + ['alt' => $this->_('Indexer les notices'), + 'class' => 'ico', + 'title' => $this->_('Indexer les notices du domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagAnchor($this->url(['action' => 'paniers', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('basket', + $this, + ['alt' => $this->_('Paniers'), + 'class' => 'ico', + 'title' => $this->_('Paniers rattachés au domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagPreview($this->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'id_catalogue' => $this->catalogue->getId()], + null, true), + $this->_('Visualiser le domaine "%s" dans un nouvel onglet', $this->catalogue->getLibelle())), ['class' => 'header_actions']); +} echo $this->renderForm($this->form); diff --git a/application/modules/admin/views/scripts/catalogue/paniers.phtml b/application/modules/admin/views/scripts/catalogue/paniers.phtml index 1f4d0643c3074586722a06bc5255c8133d3ee21a..3992de903a85258bc4244dc002e03e8003104652 100644 --- a/application/modules/admin/views/scripts/catalogue/paniers.phtml +++ b/application/modules/admin/views/scripts/catalogue/paniers.phtml @@ -1,3 +1,34 @@ +<?php + echo $this->tag('div', + $this->tagAnchor($this->url(['action' => 'tester', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('test', + $this, + ['alt' => $this->_('Indexer les notices'), + 'class' => 'ico', + 'title' => $this->_('Indexer les notices du domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagAnchor($this->url(['action' => 'edit', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('edit', + $this, + ['alt' => $this->_('Modifier'), + 'class' => 'ico', + 'title' => $this->_('Modifier le domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagPreview($this->url(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'id_catalogue' => $this->catalogue->getId()], + null, true), + $this->_('Visualiser le domaine "%s" dans un nouvel onglet', $this->catalogue->getLibelle())), + ['class' => 'header_actions']); + +?> <ul> <?php diff --git a/application/modules/admin/views/scripts/catalogue/tester.phtml b/application/modules/admin/views/scripts/catalogue/tester.phtml index f38132fda15cf141e461d12385b60b87a2a81843..179abfb8eb3fe03a34543f6d4581279dfe8e56a8 100644 --- a/application/modules/admin/views/scripts/catalogue/tester.phtml +++ b/application/modules/admin/views/scripts/catalogue/tester.phtml @@ -1,6 +1,26 @@ <?php -if (Class_Users::isCurrentUserSuperAdmin()) - echo '<p style="font-weight:bold; font-size: 0.9em">' . $this->requete . '</p>'; + echo $this->tag('div', + $this->tagAnchor($this->url(['action' => 'edit', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('edit', + $this, + ['alt' => $this->_('Modifier'), + 'class' => 'ico', + 'title' => $this->_('Modifier le domaine "%s"', + $this->catalogue->getLibelle())])) + . + $this->tagAnchor($this->url(['action' => 'paniers', + 'id_catalogue' => $this->catalogue->getId()]), + Class_Admin_Skin::current() + ->renderActionIconOn('basket', + $this, + ['alt' => $this->_('Paniers'), + 'class' => 'ico', + 'title' => $this->_('Paniers rattachés au domaine "%s"', + $this->catalogue->getLibelle())])), + ['class' => 'header_actions']); + if ($this->error) echo '<p align="center" class="error">' . $this->error . '.</p>'; @@ -10,46 +30,23 @@ if (!$this->notices) else { echo $this->ligneInfos($this->_('Notices trouvées'), $this->nb_notices); echo $this->ligneInfos($this->_('Avec vignettes en cache'), $this->avec_vignettes); - echo $this->ligneInfos($this->_('Temps d\'éxécution de la requête'), $this->temps_execution); } -if ($this->notices) { ?> - <br> - <table cellspacing="0" cellpadding="0"> - <tr class="soustitre"> - <td style="width:2%;"> </td> - <td style="width:60%"><?php echo $this->_('Titre'); ?></td> - <td style="width:38%"><?php echo $this->_('Auteur'); ?></td> - </tr> - <tr><td colspan="6" class="separ"></td></tr> -<?php - $ligne = 0; - foreach ($this->notices as $notice) - { - $ligne ++; - if ($ligne & 1) - $class="first"; - else - $class="second"; - echo '<tr class="' . $class . '">' . - '<td align="center" style="padding:3px 5px 3px 0px">'.$this->iconeSupport($notice->getTypeDoc()).'</td>' . - '<td>' . $notice->getTitrePrincipal() . '</td>'. - '<td>' . $notice->getAuteurPrincipal() . '</td> - </tr>'; - } - - echo '<tr><td colspan="6" class="separ"></td></tr>'; - echo '</table>'; - echo '<p style="margin-top:1px;"><small>' . $this->_('Information : Affichage des 20 premières notices uniquement...') . '</small></p> '; -} ?> - - <br> -<?php + +if ($this->notices) { + echo $this->listeNotices_Tableau($this->notices, + ['liste_codes' => 'T;J;A;N']); +} + + +echo $this->tagNotice('Affichage des 20 premières notices uniquement.'); + +if (!$this->isPopup()) echo $this->button((new Class_Entity()) - ->setText($this->_('Modifier le domaine ')) - ->setAttribs(['title' => $this->_('Modifier le domaine : %s', - $this->catalogue->getLibelle())]) - ->setUrl($this->url(['action' => 'edit', - 'id_catalogue' => $this->catalogue->getId()])) - ->setImage($this->tagImg(Class_Admin_Skin::current() - ->getIconUrl('buttons', 'configuration')))); + ->setText($this->_('Modifier le domaine ')) + ->setAttribs(['title' => $this->_('Modifier le domaine : %s', + $this->catalogue->getLibelle())]) + ->setUrl($this->url(['action' => 'edit', + 'id_catalogue' => $this->catalogue->getId()])) + ->setImage($this->tagImg(Class_Admin_Skin::current() + ->getIconUrl('buttons', 'configuration')))); diff --git a/application/modules/opac/views/scripts/panier/add-selection.phtml b/application/modules/opac/views/scripts/panier/add-selection.phtml index 16548345ae66b638107bc8a03a5a13242dbf0178..83cd1ab4b51019e46c96cc382586aace34547499 100644 --- a/application/modules/opac/views/scripts/panier/add-selection.phtml +++ b/application/modules/opac/views/scripts/panier/add-selection.phtml @@ -18,7 +18,9 @@ $actions = $this->tag('div', $this->tagAnchor($this->url(['controller' => 'panie echo $this->tag('div', $this->tag('p', $this->_('Ajouter ma sélection au panier "%s" ?', - $this->panier->getLibelle()), + (Class_Users::isCurrentUserCanAccesBackend() + ? $this->panier->getLibelleForAdmins() + : $this->panier->getLibelle())), ['class' => 'center']) . $actions); diff --git a/library/Class/Bib.php b/library/Class/Bib.php index 21a07d6411bf036fa0bb5faaf1850bb0abf9dca5..32a8e4217b26b18f090736e1b97f3304cf220cff 100644 --- a/library/Class/Bib.php +++ b/library/Class/Bib.php @@ -851,7 +851,7 @@ class Class_Bib extends Storm_Model_Abstract { } - public function getFacet() { + public function asBookmark() { return Class_Bib::CODE_FACETTE . $this->getIdSite(); } diff --git a/library/Class/Catalogue.php b/library/Class/Catalogue.php index 4f295276b1f751c05fa33f779ed636da5d091371..d6d2b551d0c07426927dad6e775ed7af15bc31cf 100644 --- a/library/Class/Catalogue.php +++ b/library/Class/Catalogue.php @@ -712,11 +712,6 @@ class Class_Catalogue extends Storm_Model_Abstract { } - public function getFacette() { - return $this->getFacetCode(); - } - - public function getAllNoticeIdsForDomaine($nb_par_page,$numero_page) { $preferences = $this->toArray(); @@ -1033,7 +1028,9 @@ class Class_Catalogue extends Storm_Model_Abstract { } $paniers=$this->getPanierNotices(); foreach ($paniers as $panier) { - $data_panier[]=$panier->toDataForJson(); + $json = $panier->toDataForJson(); + $json['label'] = htmlspecialchars($panier->getLibelleForAdmins()); + $data_panier[] = $json; } return $this->toDataForJsonWithCategoriesItems($data_domaines, $data_panier, $options); @@ -1275,11 +1272,16 @@ class Class_Catalogue extends Storm_Model_Abstract { } - public function getFacet() { + public function asBookmark() { + return $this->getThesaurusFacetCode(); + } + + + public function getThesaurusFacetCode() { if(!$thesaurus = Class_CodifThesaurus::findThesaurusForCatalogue($this->getId())) return ''; - return $thesaurus->getFacetteIndex(); + return $thesaurus->getFacetCode(); } @@ -1339,6 +1341,19 @@ class Class_Catalogue extends Storm_Model_Abstract { } + public function indexWithBaskets() { + if (!$this->hasIndexer()) + return $this; + + $this->index(); + foreach($this->getPanierNotices() as $basket) { + $basket->index(); + } + + return $this; + } + + public function getTitre() { return $this->getLibelle(); } diff --git a/library/Class/CodifAnnexe.php b/library/Class/CodifAnnexe.php index f18c12368caaa2b278e9dfc625368d71b41bea2d..a9b366c02ffca1d0e914b9d4ca9b649109c97a58 100644 --- a/library/Class/CodifAnnexe.php +++ b/library/Class/CodifAnnexe.php @@ -97,7 +97,7 @@ class Class_CodifAnnexe extends Storm_Model_Abstract { } - public function getFacet() { + public function asBookmark() { return $this->getFacetteIndex(); } diff --git a/library/Class/IntBib.php b/library/Class/IntBib.php index d0dc1ae2a7a84b5b7b4728b6cad9d8171e3efc0d..dbe58101bb04f7c9d74b82acd1386c5e45666382 100644 --- a/library/Class/IntBib.php +++ b/library/Class/IntBib.php @@ -184,7 +184,7 @@ class Class_IntBib extends Storm_Model_Abstract { } - public function getFacet() { + public function asBookmark() { return Class_Bib::CODE_FACETTE . $this->getIdBib(); } diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index dc2ce5765f651bc011780969417d00eb1ea4b27a..bb698b7aeac6daef765c4e22e6b46b1d30a8493a 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -273,7 +273,7 @@ class Class_MoteurRecherche { if(!$domain_id) return ''; - if(!$facette = Class_Catalogue::find($domain_id)->getFacette()) + if(!$facette = Class_Catalogue::find($domain_id)->getFacetCode()) return ''; return 'MATCH(facettes) AGAINST(\'' . trim($facette) . '\' IN BOOLEAN MODE)'; diff --git a/library/Class/MoteurRecherche/Facettes.php b/library/Class/MoteurRecherche/Facettes.php index 222313813808eaf4c9e574a2b6cd81a897e0684e..4d3369999b7bdbb1042ac74a749f5862f287c7df 100644 --- a/library/Class/MoteurRecherche/Facettes.php +++ b/library/Class/MoteurRecherche/Facettes.php @@ -206,7 +206,7 @@ class Class_MoteurRecherche_Facettes { $user_bookmarks_codes = array_map(function($model) { - return $model->getFacet(); + return $model->asBookmark(); }, $user_bookmarks); diff --git a/library/Class/Notice.php b/library/Class/Notice.php index a471e638417fc72d88bc8400b51e0b50c58af6a2..1caa0519700de837198c4ec9ddc6b1fb1ab6c84d 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1903,7 +1903,9 @@ class Class_Notice extends Storm_Model_Abstract { if (!Class_NoticeDomain::findFirstBy($params)) Class_NoticeDomain::newInstance($params)->save(); - $facets[] = $domain->getFacette(); + $facets[] = $domain->getFacetCode(); + if ($domain->hasIndexer()) + $facets[] = $domain->getThesaurusFacetCode(); } if (!empty($facets)) diff --git a/library/Class/NoticeDomain.php b/library/Class/NoticeDomain.php index bc050d23353555f7bf5433e4f45496c886159795..b3d78fd86475e225d98387846388758aede8245d 100644 --- a/library/Class/NoticeDomain.php +++ b/library/Class/NoticeDomain.php @@ -75,10 +75,11 @@ class NoticeDomainLoader extends Storm_Model_Loader { public function updateRecordsFacette($domain_id) { - if ($catalogue = Class_Catalogue::find($domain_id)) { - foreach (Class_NoticeDomain::getRecordsForDomain($domain_id) as $record) - $record->updateFacette($catalogue->getFacette())->save(); - } + if (!$catalogue = Class_Catalogue::find($domain_id)) + return; + + foreach (Class_NoticeDomain::getRecordsForDomain($domain_id) as $record) + $record->updateFacette($catalogue->getFacetCode())->save(); } @@ -153,12 +154,12 @@ class Class_NoticeDomain extends Storm_Model_Abstract { if (1 < $existing) return; - $record->deleteFacettes($domain->getFacette())->save(); + $record->deleteFacettes($domain->getFacetCode())->save(); } protected function _updateRecordFacets($record, $domain) { - $record->updateFacette($domain->getFacette())->save(); + $record->updateFacette($domain->getFacetCode())->save(); } diff --git a/library/Class/Users.php b/library/Class/Users.php index 8ab61505e43f27e4cf86cc465e3549f23af37f6c..b1a9513cad1ea8b95c2a41f6a2d595f18b02d094 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1217,7 +1217,9 @@ class Class_Users extends Storm_Model_Abstract { public function getPanierCourant() { - return ($panier_courant = parent::getPanierCourant()) ? $panier_courant : Class_PanierNotice::newForUser($this); + return ($panier_courant = parent::getPanierCourant()) + ? $panier_courant + : Class_PanierNotice::newForUser($this); } diff --git a/library/ZendAfi/View/Helper/Panier/Table.php b/library/ZendAfi/View/Helper/Panier/Table.php index 1cfb00cfbd29633655c8432159d9f67978d52978..7eb4a24533a9f82ca7a0d2b7170490897942a3d2 100644 --- a/library/ZendAfi/View/Helper/Panier/Table.php +++ b/library/ZendAfi/View/Helper/Panier/Table.php @@ -90,7 +90,8 @@ class ZendAfi_View_Helper_Panier_Table extends ZendAfi_View_Helper_BaseHelper { 'controller' => 'catalogue', 'action' => 'paniers', 'id_catalogue' => $catalogue->getId()], - $catalogue->getLibelle()); + $catalogue->getLibelle(), + ['class' => 'not_admin_tool']); $links = $this->view->tag('div', implode(', ', $catalogue_links)); } diff --git a/library/digital_resources/Bibliondemand/Lib/Context.php b/library/digital_resources/Bibliondemand/Lib/Context.php index b63a6208eff5df5b3dc70e01194e333a67dfb22b..c4604376e4eb7d736ce008f1ada1591d152877ad 100644 --- a/library/digital_resources/Bibliondemand/Lib/Context.php +++ b/library/digital_resources/Bibliondemand/Lib/Context.php @@ -139,7 +139,7 @@ class Bibliondemand_Lib_Context { public function getLibraryFacet() { return ($library = $this->getLibrary()) - ? $library->getFacet() + ? $library->getFacetCode() : ''; } diff --git a/public/admin/css/front_nav.css b/public/admin/css/front_nav.css index 55186356e1de9e15ab9b83dfe33a6067e61d125f..0defe3a6c451c693abd2f84e806f91873bb480a2 100644 --- a/public/admin/css/front_nav.css +++ b/public/admin/css/front_nav.css @@ -115,7 +115,7 @@ width: 270px; } -#site_web_wrapper[data-show_admin_icons="true"] a[href*="/admin"] { +#site_web_wrapper[data-show_admin_icons="true"] a[href*="/admin"]:not(.not_admin_tool) { display: inline-block !important; } @@ -135,7 +135,7 @@ #site_web_wrapper .footer a[href*="/admin"], #site_web_wrapper .admin_tools_lock, #site_web_wrapper .configuration_module, -#site_web_wrapper a[href*="/admin"] { +#site_web_wrapper a[href*="/admin"]:not(.not_admin_tool) { display: none !important; } diff --git a/tests/application/modules/admin/controllers/CatalogueControllerTest.php b/tests/application/modules/admin/controllers/CatalogueControllerTest.php index 4cd4b1029934b878e0a876024a0ee0772f81ed72..0d36513e06fea794e300202cc04087031c7391d4 100644 --- a/tests/application/modules/admin/controllers/CatalogueControllerTest.php +++ b/tests/application/modules/admin/controllers/CatalogueControllerTest.php @@ -154,6 +154,9 @@ abstract class AdminCatalogueControllerTestCase extends AbstractControllerTestCa ->answers(10) ->whenCalled('fetchAll') + ->answers(null) + + ->whenCalled('query') ->answers(null); $this->_catalogue_adultes->setThesaurus('THEM123;GENR231'); @@ -546,7 +549,7 @@ class CatalogueControllerWithAModoBibWithRightAccesDomainesIndexTest extends Adm -class CatalogueControllerActionTesterNoIndexationTest extends AbstractControllerTestCase { +class CatalogueControllerActionTesterNoIndexationTest extends AdminCatalogueControllerTestCase { protected $_storm_default_to_volatile = true; @@ -566,17 +569,33 @@ class CatalogueControllerActionTesterNoIndexationTest extends AbstractController 'type_doc' => '', 'indexer' =>true]); - $this->dispatch('admin/catalogue/tester/id_catalogue/6', true); } -/** @test */ + + /** @test */ public function withNoCriteriaShouldDisplayNoIndexationPossible() { - $this->assertXPathContentContains('//p[@class="error"]','Le domaine ne ne peut pas être mis en favori utilisateur sans critères d\'indexation'); + $this->dispatch('admin/catalogue/tester/id_catalogue/6', true); + + $this->assertXPathContentContains('//p[@class="error"]','Le domaine ne peut pas être mis en favori utilisateur sans critères d\'indexation'); } + + /** @test */ + public function withBasketsShouldNotDisplayNoIndexationPossible() { + Class_Catalogue::find(6) + ->addPanierNotice($this->fixture('Class_PanierNotice', + ['id' => 9])) + ->assertSave(); + + $this->dispatch('admin/catalogue/tester/id_catalogue/6', true); + + $this->assertNotXPathContentContains('//p[@class="error"]','Le domaine ne peut pas'); + } } + + class CatalogueControllerActionTesterTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; @@ -606,27 +625,29 @@ class CatalogueControllerActionTesterTest extends AbstractControllerTestCase { /** @test */ - public function pageShouldDisplayRequest() { - $this->assertContains("select * from notices Where (MATCH(facettes) AGAINST(' +(B1) +( D78308*)' IN BOOLEAN MODE) and notices.type_doc IN ('1', '3', '4', '5') and annee >= '2012' and annee <= '2012') and type=1 order by alpha_titre LIMIT 0,20", - $this->_response->getBody()); + public function noResultMessageShouldBePresent() { + $this->assertXPathContentContains('//p', 'Ce domaine ne renvoie aucun résultat.'); } /** @test */ - public function noResultMessageShouldBePresent() { - $this->assertXPathContentContains('//p', 'Ce domaine ne renvoie aucun résultat.'); + public function pageShouldContainsLinkToEdit() { + $this->assertXPath('//a[contains(@href, "/edit/id_catalogue/6")]'); } /** @test */ - public function modifyLinkShouldContainsSlashes() { - $this->assertXPathContentContains('//button[contains(@onclick, "/admin/catalogue/edit/id_catalogue/6")]', "Modifier le domaine"); + public function pageShouldContainsLinkToBaskets() { + $this->assertXPath('//a[contains(@href, "/paniers/id_catalogue/6")]'); } } + class CatalogueControllerActionTesterWithEmptyDomainTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + protected function _loginHook($account) { $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN; } @@ -788,8 +809,20 @@ class CatalogueControllerEditCatalogueTest extends AdminCatalogueControllerTestC /** @test */ - public function shouldContainsPopupLinkToTestAction() { - $this->assertXPath('//a[contains(@href, "/tester/id_catalogue/6")][@data-popup]'); + public function shouldContainsPopupToTestAction() { + $this->assertXPath('//a[contains(@href, "/tester/id_catalogue/6")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToBaskets() { + $this->assertXPath('//a[contains(@href, "/paniers/id_catalogue/6")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToPreview() { + $this->assertXPath('//a[contains(@href, "/recherche/simple/id_catalogue/6")]'); } } @@ -1306,6 +1339,24 @@ class CatalogueControllerPaniersHistoireTest extends AdminCatalogueControllerTes public function pageShouldContainsPanierPreview() { $this->assertXPath('//a[contains(@href, "recherche/simple/id_panier/8")]'); } + + + /** @test */ + public function shouldContainsLinkToTestAction() { + $this->assertXPath('//a[contains(@href, "/tester/id_catalogue/100")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToEdit() { + $this->assertXPath('//a[contains(@href, "/edit/id_catalogue/100")]'); + } + + + /** @test */ + public function pageShouldContainsLinkToPreview() { + $this->assertXPath('//a[contains(@href, "/recherche/simple/id_catalogue/100")]'); + } } diff --git a/tests/application/modules/opac/controllers/AbonneControllerPaniersTest.php b/tests/application/modules/opac/controllers/AbonneControllerPaniersTest.php index 95d46b10961ba16d6ef8d70ad56531ad7e1a5bbc..007beb22092dfb824593b79c248c7da5d667ad9e 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPaniersTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPaniersTest.php @@ -16,41 +16,69 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class AbonneControllerPaniersForMarcusTest extends AbstractControllerTestCase { - protected + protected + $_storm_default_to_volatile = true, $marcus, - $_xpath, + $_xpath, $_json, $panier_bd; public function setup() { parent::setup(); - - $this->marcus = Class_Users::newInstanceWithId(45) - ->setIdabon(45) - ->setPrenom('James') - ->setNom('Bond'); + + $this->marcus = $this->fixture('Class_Users', + ['id' => 45, + 'idabon' => 45, + 'login' => 'marcus', + 'password' => 'secret', + 'prenom' => 'marcus', + 'nom' => 'bond']); + + $marcel = $this->fixture('Class_Users', + ['id' => 47, + 'login' => 'marcel', + 'password' => 'secret', + 'prenom' => 'marcel', + 'nom' => 'doob']); + $marcel->beAdminPortail()->assertSave(); + + $coups_coeur_marcel = $this->fixture('Class_PanierNotice', + ['id' => 4, + 'id_panier' => 2, + 'libelle' => 'Mes coups de coeur', + 'date_maj' => '10/02/2011', + 'notices' => 'POMME API', + 'user' => $marcel]); + + $domaine_coups_coeur = $this->fixture('Class_Catalogue', + ['id' => 1, + 'libelle' => 'Coups de coeur', + 'panier_notices' => [$coups_coeur_marcel]]); + ZendAfi_Auth::getInstance()->logUser($this->marcus); - $this->panier_bd = Class_PanierNotice::newInstanceWithId(2, - ['id_panier' => 1, - 'libelle' => 'Mes BD', - 'date_maj' => '10/02/2011', - 'notices' => 'COMBAT ORDINAIRE;BLACKSAD', - 'user' => $this->marcus]); - + $this->panier_bd = $this->fixture('Class_PanierNotice', + ['id' => 2, + 'id_panier' => 1, + 'libelle' => 'Mes BD', + 'date_maj' => '10/02/2011', + 'notices' => 'COMBAT ORDINAIRE;BLACKSAD', + 'user' => $this->marcus]); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_PanierNotice') ->whenCalled('findAllBy') ->answers([$this->panier_bd]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') ->whenCalled('findTopCatalogues') - ->answers([]); + ->answers([$domaine_coups_coeur]); } @@ -61,7 +89,7 @@ class AbonneControllerPaniersForMarcusTest extends AbstractControllerTestCase { $this->dispatch('abonne/get-paniers.json',true); $this->assertJsonStringEqualsJsonString( - $this->_response->getBody(), + $this->_response->getBody(), json_encode([ ["id" => "panier_for_user", "label" => "Mes paniers", @@ -71,9 +99,25 @@ class AbonneControllerPaniersForMarcusTest extends AbstractControllerTestCase { "label" => "Mes BD", "options" => ["ico" => BASE_URL."/public/admin/images/picto/paniers_16.png"]]], "options" => ["multipleSelection" => false]], - ["id" => "domaines_paniers", + + [ + "id" => "domaines_paniers", "label" => "Domaines", - "categories" => [], + "categories" => [ + ['id' => 1, + 'label' => 'Coups de coeur', + 'categories' => [], + 'items' => [ + ['id' => 4, + 'label' => 'Mes coups de coeur - marcel doob', + 'options' => [ + 'ico' => BASE_URL.'/public/admin/images/picto/paniers_16.png']] + ], + + 'options' => ['ico' => BASE_URL.'/public/admin/images/picto/domaines_16.png', + 'removeCheckbox' => true] + ] + ], "items" => [], "options" => ["ico" => BASE_URL."/public/admin/images/picto/domaines_16.png", "multipleSelection" => false]]]), @@ -88,7 +132,7 @@ class AbonneControllerPaniersForMarcusTest extends AbstractControllerTestCase { $this->dispatch('abonne/get-paniers.json',true); $this->assertJsonStringEqualsJsonString( - $this->_response->getBody(), + $this->_response->getBody(), json_encode([ ["id" => "panier_for_user", "label" => "Mes paniers", diff --git a/tests/application/modules/opac/controllers/PanierControllerTest.php b/tests/application/modules/opac/controllers/PanierControllerTest.php index 8ae056dded830f19986cc6bb28bb83303be23037..7fcd93c9ff76fdfdf046371886cc1918a6c9c534 100644 --- a/tests/application/modules/opac/controllers/PanierControllerTest.php +++ b/tests/application/modules/opac/controllers/PanierControllerTest.php @@ -1833,7 +1833,15 @@ class PanierControllerDomainActionTest extends PanierControllerTestCase { /** @test */ public function tableShouldContainsSelectionJeunesse() { - $this->assertXPathContentContains('//div//table', 'selection jeunesse'); + $this->assertXPathContentContains('//div//table//td', + 'selection jeunesse'); + } + + + /** @test */ + public function domainLinkShouldHaveClassNotAdminTool() { + $this->assertXPathContentContains('//div//table//td//a[@class="not_admin_tool"]', + 'histoire'); } } diff --git a/tests/library/Class/ArticleTest.php b/tests/library/Class/ArticleTest.php index e773cd5676401ef7f27c3c8a3ad043cb4ab14265..5f2fd33fdaad095734f60a5d7e658a35d0e0709d 100644 --- a/tests/library/Class/ArticleTest.php +++ b/tests/library/Class/ArticleTest.php @@ -1184,7 +1184,8 @@ class ArticleIndexAllTest extends ModelTestCase { /** @test */ public function recordShouldHaveExpectedFacette() { - $this->assertContains(Class_Catalogue::find(1)->getFacette(), Class_Notice::find(2)->getFacettes()); + $this->assertContains(Class_Catalogue::find(1)->getFacetCode(), + Class_Notice::find(2)->getFacettes()); } diff --git a/tests/library/Class/PanierNoticeTest.php b/tests/library/Class/PanierNoticeTest.php index aff31c8a0793ff30f5d9f73fe6e63220bb022605..b762462b936177c141170b1fd4e2d37cd454b0ab 100644 --- a/tests/library/Class/PanierNoticeTest.php +++ b/tests/library/Class/PanierNoticeTest.php @@ -421,8 +421,10 @@ class PanierNoticeIndexAllTest extends ModelTestCase { public function setUp() { parent::setUp(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Catalogue') - ->whenCalled('saveThesaurus')->answers(true); + Zend_Registry::set('sql', + Storm_Test_ObjectWrapper::mock() + ->whenCalled('query') + ->answers(null)); $this->fixture('Class_Notice', ['id' => 4, 'titre_principal' => 'Le Montespan', @@ -490,7 +492,21 @@ class PanierNoticeIndexAllTest extends ModelTestCase { /** @test */ public function facetOfRecordMontespanShouldContainsFacetQ1() { - $this->assertContains('Q1', Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes()); + $this->assertEquals('Q1', + Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes()); + } + + + /** @test */ + public function withBookmarkableDomainFacetOfRecordMontespanShouldContainsFacetHCCCC() { + $domain = Class_Catalogue::find(1); + $domain + ->setIndexer(true) + ->assertSave(); + $domain->indexWithBaskets(); + + $this->assertEquals('Q1 HCCCC0001', + Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes()); } @@ -502,6 +518,7 @@ class PanierNoticeIndexAllTest extends ModelTestCase { /** @test */ public function recordMonstespanShouldNotHaveFacetQ2() { - $this->assertNotContains('Q2', Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes()); + $this->assertNotContains('Q2', + Class_Notice::findFirstBy(['clef_alpha' => 'MONTESPAN'])->getFacettes()); } } diff --git a/tests/scenarios/SearchSelection/SearchSelectionTest.php b/tests/scenarios/SearchSelection/SearchSelectionTest.php index b3e8038cb0c1ee5363d25371066e4567fe81af5b..0e1c935438f99327e65f694917183e59b87c6b01 100644 --- a/tests/scenarios/SearchSelection/SearchSelectionTest.php +++ b/tests/scenarios/SearchSelection/SearchSelectionTest.php @@ -441,7 +441,6 @@ abstract class SearchSelectionAddToCartWithUserTestCase extends SearchSelectionT 'libelle' => 'my cart', 'date_maj' => '25/05/2010', 'notices' => '', - 'user' => $this->user, 'catalogues' => [$histoire]]); $this->user = $this->fixture('Class_Users', @@ -450,6 +449,7 @@ abstract class SearchSelectionAddToCartWithUserTestCase extends SearchSelectionT 'nom' => 'john', 'login' => 'jzorn', 'password' => '123', + 'panier_notices' => [$this->cart], 'panier_courant' => $this->cart]); ZendAfi_Auth::getInstance()->logUser($this->user); @@ -501,6 +501,47 @@ class SearchSelectionAddToCartTest extends SearchSelectionAddToCartWithUserTestC +class SearchSelectionAddToCartWithOtherUserCartAsCurrentCartTest extends SearchSelectionAddToCartWithUserTestCase { + public function setUp() { + parent::setUp(); + + $other_user = $this->fixture('Class_Users', + ['id' => 29, + 'nom' => 'mero', + 'prenom' => 'cali', + 'login' => 'cali', + 'password' => 'jedispas']); + + $other_cart = $this->fixture('Class_PanierNotice', + ['id' => 4, + 'id_panier' => 4, + 'libelle' => 'favorites', + 'date_maj' => '25/05/2010', + 'notices' => '', + 'user' => $other_user, + 'catalogues' => [Class_Catalogue::find(97)]]); + + + $this->user + ->beAdminPortail() + ->setPanierCourant($other_cart) + ->assertSave(); + + + $this->dispatch('/panier/add-selection', true); + } + + + /** @test */ + public function pageShouldContainsLinkAddToCalimeroFavorites() { + $this->assertXPathContentContains('//p', 'Ajouter ma sélection au panier "favorites - cali mero"', + $this->_response->getBody()); + } +} + + + + class SearchSelectionPostAddSelectionToCartTest extends SearchSelectionAddToCartWithUserTestCase { public function setUp() { parent::setUp();