diff --git a/VERSIONS_WIP/5524 b/VERSIONS_WIP/5524 new file mode 100644 index 0000000000000000000000000000000000000000..2e03ed7187ee8658c827ddcf029acaa89d09232e --- /dev/null +++ b/VERSIONS_WIP/5524 @@ -0,0 +1 @@ + - ticket #5524 : Ajout d'une nouvelle rubrique dépouillement dans l'affichage des notices. \ No newline at end of file diff --git a/application/modules/opac/controllers/NoticeajaxController.php b/application/modules/opac/controllers/NoticeajaxController.php index 16af1df81de0db388b2c6628285f0e49bf0de28a..5ef23fdb56ca12d7ab0cf3c4fd931a756d3efe26 100644 --- a/application/modules/opac/controllers/NoticeajaxController.php +++ b/application/modules/opac/controllers/NoticeajaxController.php @@ -173,11 +173,6 @@ class NoticeAjaxController extends Zend_Controller_Action { return; } - if ('' != ($html = $this->view->Notice_Analytics($notice))) { - $this->_sendResponseWithScripts($html); - return; - } - if ($notice->isPeriodique()) { $periodiques = $this->notice->getArticlesPeriodique($this->id_notice); $this->_sendResponseWithScripts($this->notice_html->getArticlesPeriodique($periodiques)); @@ -188,6 +183,17 @@ class NoticeAjaxController extends Zend_Controller_Action { } + public function recountsAction() { + if (!$notice = Class_Notice::find($this->id_notice)) { + $this->_sendResponse(''); + return; + } + + $this->_sendResponseWithScripts($this->view->Notice_Analytics($notice)); + return; + } + + public function similairesAction() { $notices = $this->notice->getNoticesSimilaires(); $html = $this->notice_html->getListeNotices($notices, $this->view); diff --git a/library/Class/CodifAuteur.php b/library/Class/CodifAuteur.php index 61a804dc17de3014eacc033fe8f8fbc3265fa6ad..759737f2bb8b51045cb95e27a782ff6f6cd937f8 100644 --- a/library/Class/CodifAuteur.php +++ b/library/Class/CodifAuteur.php @@ -21,6 +21,15 @@ class CodifAuteurLoader extends Storm_Model_Loader { + public function findByLastNameFirstName($lastname, $firstname) { + $code_alpha = str_replace(' ', + 'x', + Class_Indexation::getInstance() + ->alphaMaj($lastname . '|' . $firstname)); + return Class_CodifAuteur::findByCodeAlpha($code_alpha); + } + + public function findOrCreate($code_alpha, $auteur) { $existing = Class_CodifAuteur::findByCodeAlpha($code_alpha); diff --git a/library/Class/Codification.php b/library/Class/Codification.php index 647bde19676b148c3ba53fa5dada902ac8b8fd18..f5ec4d2a215803d713365ce37b66f9db3e22f2e9 100644 --- a/library/Class/Codification.php +++ b/library/Class/Codification.php @@ -91,14 +91,14 @@ class Class_Codification { if($tous == true) $combo.='<option value="">tous</option>'; $v=explode(chr(13).chr(10),$data); for($i=0; $i<count($v); $i++) - { - $elem=explode(":",$v[$i]); - if(trim($elem[0])>"") { - if($valeur==$elem[0]) $selected=" selected"; else $selected=""; - $combo.='<option value="'.$elem[0].'"'.$selected.'>'.stripSlashes($elem[1]).'</option>'; + $elem=explode(":",$v[$i]); + if(trim($elem[0])>"") + { + if($valeur==$elem[0]) $selected=" selected"; else $selected=""; + $combo.='<option value="'.$elem[0].'"'.$selected.'>'.stripSlashes($elem[1]).'</option>'; + } } - } $combo.='</select>'; return $combo; } @@ -240,23 +240,24 @@ class Class_Codification { $translate = Zend_Registry::get('translate'); $this->_nom_onglets = [ - "detail" => Class_Onglet::forLibelleAndType($translate->_("Description du document"),'detail'), - "avis" => Class_Onglet::forLibelleAndType($translate->_("Critiques"),'avis'), - "exemplaires" => Class_Onglet::forLibelleAndType($translate->_("Exemplaires"),'exemplaires'), - "resume" => Class_Onglet::forLibelleAndType($translate->_("Résumés"),'resume'), - "tags" => Class_Onglet::forLibelleAndType($translate->_("Rebondir dans le catalogue"),'tags'), - "biographie" => Class_Onglet::forLibelleAndType($translate->_("Biographie de l'auteur"),'biographie'), - "series" => Class_Onglet::forLibelleAndType($translate->_("Documents de la même série"),'series')->setDisplayMethod('checkIfClefChapeauExists'), + "detail" => Class_Onglet::forLibelleAndType($translate->_("Description du document"),'detail'), + "avis" => Class_Onglet::forLibelleAndType($translate->_("Critiques"),'avis'), + "exemplaires" => Class_Onglet::forLibelleAndType($translate->_("Exemplaires"),'exemplaires'), + "resume" => Class_Onglet::forLibelleAndType($translate->_("Résumés"),'resume'), + "tags" => Class_Onglet::forLibelleAndType($translate->_("Rebondir dans le catalogue"),'tags'), + "biographie" => Class_Onglet::forLibelleAndType($translate->_("Biographie de l'auteur"),'biographie'), + "series" => Class_Onglet::forLibelleAndType($translate->_("Documents de la même série"),'series')->setDisplayMethod('hasClefChapeau'), // "auteur" => Class_Onglet::forLibelleAndType($translate->_("Documents du même auteur"),'auteur'), - "similaires" => Class_Onglet::forLibelleAndType($translate->_("Documents similaires"),'similaires'), - "bibliographie" => Class_Onglet::forLibelleAndType($translate->_("Discographie"),'bibliographie'), - "morceaux" => Class_Onglet::forLibelleAndType($translate->_("Morceaux"),'morceaux'), - "bandeAnnonce" => Class_Onglet::forLibelleAndType($translate->_("Bande-annonce"),'bandeAnnonce'), - "photos" => Class_Onglet::forLibelleAndType($translate->_("Photos"),'photos'), - "videos" => Class_Onglet::forLibelleAndType($translate->_("Archives vidéo"),'videos'), - "resnumeriques" => Class_Onglet::forLibelleAndType($translate->_("Ressources numériques"),'resnumeriques')->setDisplayMethod('checkIfHasRessourcesNumeriques'), - "babeltheque" => Class_Onglet::forLibelleAndType($translate->_('Babelthèque'),'babeltheque'), - 'frbr' => Class_Onglet::forLibelleAndType($translate->_('Notices liées'),'frbr')->setDisplayMethod('checkIfHasNoticesLiees')]; + "similaires" => Class_Onglet::forLibelleAndType($translate->_("Documents similaires"),'similaires'), + "bibliographie" => Class_Onglet::forLibelleAndType($translate->_("Discographie"),'bibliographie'), + "morceaux" => Class_Onglet::forLibelleAndType($translate->_("Morceaux"),'morceaux'), + "bandeAnnonce" => Class_Onglet::forLibelleAndType($translate->_("Bande-annonce"),'bandeAnnonce'), + "photos" => Class_Onglet::forLibelleAndType($translate->_("Photos"),'photos'), + "videos" => Class_Onglet::forLibelleAndType($translate->_("Archives vidéo"),'videos'), + "resnumeriques" => Class_Onglet::forLibelleAndType($translate->_("Ressources numériques"),'resnumeriques')->setDisplayMethod('hasNumericRessources'), + "babeltheque" => Class_Onglet::forLibelleAndType($translate->_('Babelthèque'),'babeltheque'), + 'frbr' => Class_Onglet::forLibelleAndType($translate->_('Notices liées'),'frbr')->setDisplayMethod('hasLinkedNotices'), + 'recounts' => Class_Onglet::forLibelleAndType($this->_('Contient'), 'recounts')->setDisplayMethod('hasRecounts')]; } @@ -283,12 +284,12 @@ class Class_Codification { $message = 'Voir tous les tomes'; switch ($notice->getTypeDoc()) { - case Class_TypeDoc::PERIODIQUE: - $message = 'Voir tous les numéros'; - break; - case Class_TypeDoc::DVD: - $message = 'Voir tous les épisodes'; - break; + case Class_TypeDoc::PERIODIQUE: + $message = 'Voir tous les numéros'; + break; + case Class_TypeDoc::DVD: + $message = 'Voir tous les épisodes'; + break; } return self::concatLibelleWithTitreChapeau($message, $notice->getTitreChapeau()); diff --git a/library/Class/Notice.php b/library/Class/Notice.php index e4996f0919779ff078b3818818f2d75a62f285a3..53a4c5a729c4426d41a55f50c318bfface0a7cba 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -1205,12 +1205,8 @@ class Class_Notice extends Storm_Model_Abstract { $prenom = $item[1]; $fonction = $item[2]; $fonction_pergame = $item[3]; - $code_alpha = $indexation->alphaMaj($nom . '|' . $prenom); - $code_alpha = str_replace(' ', 'x', $code_alpha); - if (!$code_alpha) - return []; - if (!$codif_auteur = Class_CodifAuteur::findByCodeAlpha($code_alpha)) + if (!$codif_auteur = Class_CodifAuteur::findByLastNameFirstName($nom, $prenom)) return []; if ($fonction_pergame) diff --git a/library/Class/Onglet.php b/library/Class/Onglet.php index 73e66fad92490bfe0b429de189b5954dd87848a3..0f6689b04cc8a3b127697b901663e6e9fafb2a5a 100644 --- a/library/Class/Onglet.php +++ b/library/Class/Onglet.php @@ -95,12 +95,12 @@ class Class_Onglet { } - public function checkIfClefChapeauExists($notice) { + public function hasClefChapeau($notice) { return strlen($notice->getClefChapeau())>0; } - public function checkIfHasRessourcesNumeriques($notice) { + public function hasNumericRessources($notice) { if (1 == Class_AdminVar::isBibNumEnabled() && Class_Users::isCurrentUserAdmin()) return true; @@ -110,13 +110,18 @@ class Class_Onglet { } - public function checkIfHasNoticesLiees($notice) { + public function hasLinkedNotices($notice) { $sourceLinks = $notice->getLinksAsSource(); $targetLinks = $notice->getLinksAsTarget(); return !(0 == count($sourceLinks) and 0 == count($targetLinks)); } + public function hasRecounts($record) { + return !empty(Class_Onglet_Analytics::getRecounts($record)); + } + + public function setDisplayMode($display) { $this->display = $display; return $this; diff --git a/library/Class/Onglet/Analytics.php b/library/Class/Onglet/Analytics.php new file mode 100644 index 0000000000000000000000000000000000000000..5955a84f188e53ab1617fab0a41aaf997b71475f --- /dev/null +++ b/library/Class/Onglet/Analytics.php @@ -0,0 +1,73 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_Onglet_Analytics extends Class_Onglet { + + const PREF_ANALYTICS = 'analytics'; + const PREF_ANALYTICS_TITLE = 'analytics_title'; + const PREF_ANALYTICS_AUTHORS = 'analytics_authors'; + + const FIELD_NAME = 'code'; + const FIELD_VALUE= 'valeur'; + + + public static function getRecounts($record) { + if (!$record) + return []; + + $profil = Class_Profil::getCurrentProfil(); + $preferences = $profil + ->getCfgModulesPreferences('recherche', 'viewnotice', $record->getTypeDoc()); + + $analytics_field = $preferences[self::PREF_ANALYTICS]; + $title_field = $preferences[self::PREF_ANALYTICS_TITLE]; + $authors_field = explode(';', $preferences[self::PREF_ANALYTICS_AUTHORS]); + + if (!$analytics_field || !is_array($authors_field)) + return ''; + + $analytics = $record->get_subfield($analytics_field); + if (empty($analytics)) + return ''; + + $items = []; + foreach ($analytics as $analytic) { + $item = new Class_Onglet_AnalyticsItem(); + $subfields = $record->decoupe_bloc_champ($analytic); + foreach ($subfields as $subfield) { + if ($title_field == $subfield[self::FIELD_NAME]) { + $item->setTitle($subfield[self::FIELD_VALUE]); + continue; + } + + if (in_array($subfield[self::FIELD_NAME], $authors_field)) + $item->addAuthor($subfield[self::FIELD_VALUE]); + } + if ($item->isValid()) + $items[] = $item; + } + + return $items; + } +} + +?> \ No newline at end of file diff --git a/library/Class/Onglet/AnalyticsItem.php b/library/Class/Onglet/AnalyticsItem.php new file mode 100644 index 0000000000000000000000000000000000000000..35311a9052b2b828f06af4e5ad773bd385554560 --- /dev/null +++ b/library/Class/Onglet/AnalyticsItem.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_Onglet_AnalyticsItem { + protected + $_title = '', + $_authors=[]; + + public function setTitle($title) { + $this->_title = $title; + } + + + public function isValid() { + return '' != $this->_title; + } + + + public function addAuthor($author) { + $this->_authors[] = $author; + } + + + public function acceptVisitor($visitor) { + if (!$this->isValid()) + return $this; + + $visitor->visitTitle($this->_title); + + foreach($this->_authors as $author) + $this->acceptAuthorVisitor($author, $visitor); + } + + + public function acceptAuthorVisitor($author, $visitor) { + if (!preg_match('/([\w\s&]+)(\s*,\s*([\w-]+))?/u', $author, $matches)) + return $visitor->visitAuthor($author); + + $visitor->visitAuthorLastNameFirstName($author, + $matches[1], + isset($matches[3]) ? $matches[3] : ''); + } +} + + +?> \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Notice/Analytics.php b/library/ZendAfi/View/Helper/Notice/Analytics.php index 5f8cb1275d5fb17b809278282821c30dc2a78939..06a1683c2a85ea4b6313081412c7f4f886b26323 100644 --- a/library/ZendAfi/View/Helper/Notice/Analytics.php +++ b/library/ZendAfi/View/Helper/Notice/Analytics.php @@ -16,94 +16,66 @@ * * 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 ZendAfi_View_Helper_Notice_Analytics extends Zend_View_Helper_HtmlElement { use Trait_Translator; - const PREF_ANALYTICS = 'analytics'; - const PREF_ANALYTICS_TITLE = 'analytics_title'; - const PREF_ANALYTICS_AUTHORS = 'analytics_authors'; - const FIELD_NAME = 'code'; - const FIELD_VALUE= 'valeur'; + protected $_item_html; public function notice_analytics($notice) { - if (!$notice) - return ''; - - $preferences = Class_Profil::getCurrentProfil() - ->getCfgModulesPreferences('recherche', 'viewnotice', $notice->getTypeDoc()); - - $analytics_field = $preferences[self::PREF_ANALYTICS]; - $title_field = $preferences[self::PREF_ANALYTICS_TITLE]; - $authors_field = explode(';', $preferences[self::PREF_ANALYTICS_AUTHORS]); - - if (!$analytics_field || !is_array($authors_field)) - return ''; - - $analytics = $notice->get_subfield($analytics_field); - if (empty($analytics)) - return ''; - - $items = []; - foreach ($analytics as $analytic) { - $item = new ZendAfi_View_Helper_Notice_AnalyticsItem(); - $subfields = $notice->decoupe_bloc_champ($analytic); - foreach ($subfields as $subfield) { - if ($title_field == $subfield[self::FIELD_NAME]) { - $item->setTitle($subfield[self::FIELD_VALUE]); - continue; - } - - if (in_array($subfield[self::FIELD_NAME], $authors_field)) - $item->addAuthor($subfield[self::FIELD_VALUE]); - } - if ($item->isValid()) - $items[] = $item; - } - + $items = Class_Onglet_Analytics::getRecounts($notice); if (empty($items)) return ''; - $html = '<h3 class"notice_info_ligne_titre">' . $this->_('Contient') . '</h3><ul><li>'; - $items_html = array_map(function ($item) {return $item->html();}, + $html = '<ul><li>'; + $items_html = array_map([$this, 'renderItem'], $items); $html .= implode('</li><li>', $items_html); $html .= '</li></ul>'; return $html; } -} -class ZendAfi_View_Helper_Notice_AnalyticsItem { - protected $_title, $_authors=[]; + public function renderItem($item) { + $this->_item_html = ''; - public function setTitle($title) { - $this->_title = $title; + $item->acceptVisitor($this); + + return $this->_item_html; } - public function addAuthor($author) { - $this->_authors[] = $author; + public function visitTitle($title) { + $this->_item_html = $title; } - public function isValid() { - return '' != $this->_title; + public function visitAuthor($author) { + $this->_item_html .= ' / ' . $author; } - public function html() { - if (!$this->isValid()) - return ''; + public function visitAuthorLastNameFirstName($author, $lastname, $firstname) { + if (!$codif_auteur = Class_CodifAuteur::findByLastNameFirstName($lastname, $firstname)) + return $this->visitAuthor($author); + + $rebound = (new Class_Notice_Field()) + ->setId(Class_CodifAuteur::CODE_FACETTE) + ->setLabel($author) + ->setUrlParams(['controller' => 'recherche', + 'action' => 'simple', + 'code_rebond' => Class_CodifAuteur::CODE_FACETTE.$codif_auteur->getId(), + 'id_notice' => null, + 'facettes' => null, + 'facette' => null, + 'serie' => null, + 'page' => null]); - return $this->_title - . ((!empty($this->_authors)) - ? ' / ' . implode(' / ', $this->_authors) - : ''); + $this->_item_html .= ' / ' . $rebound->renderOn($this->view); } } ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php index ca8787ac6558ba88d5a613204f065e77df795142..2edb7010273ce43be18b4d26e29fa3c1e136a513 100644 --- a/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php +++ b/tests/application/modules/opac/controllers/NoticeAjaxControllerTest.php @@ -2162,4 +2162,56 @@ class NoticeAjaxControllerRessourceEpubPictoTypeTest extends AbstractControllerT } } -?> \ No newline at end of file + + +class NoticeAjaxControllerRecountsTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { + parent::setUp(); + + $deniau = $this->fixture('Class_CodifAuteur', + ['id' => 25, + 'code_alpha' => 'DENIAU', + 'libelle' => 'Deniau', + 'formes' => 'DENIAU']); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAuteur') + ->whenCalled('findByCodeAlpha') + ->answers(null) + + ->whenCalled('findByCodeAlpha') + ->with('DENIAU') + ->answers($deniau); + + $record = $this->fixture('Class_Notice',['id'=> 10, + 'titre_principal' => 'Un héros trés discret', + 'auteur_principal' => 'Jacques Audiard', + 'unimarc' =>file_get_contents(realpath(dirname(__FILE__)).'../../../../../fixtures/audiard_herosdiscret.uni')]); + + + + + Class_Profil::getCurrentProfil() + ->setCfgModules(['recherche' => + ['viewnotice0' => [ + 'analytics' => '702', + 'analytics_title' => '6', + 'analytics_authors' => 'a' + ]]]); + + $this->dispatch('/noticeajax/recounts/id_notice/10', true); + } + + + /** @test */ + public function deniauShouldBePresent() { + $this->assertXpathContentContains('//ul/li/a[contains(@href, "recherche/simple/code_rebond/A25")]', + utf8_encode('Deniau')); + } + + /** @test */ + public function dupontelShouldBePresent() { + $this->assertXpathContentContains('//ul/li','Acteur / Dupontel', $this->_response->getBody()); + } + +} diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index ccddbd6831f3e4014a5d95a5e2fc1d3f1ad5d31a..0a2a1988a8e6187801f0827a826c3dba05fc180a 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -880,6 +880,10 @@ class RechercheControllerViewNoticeAndResnumeriqueTabAsAdminTest extends Recherc 'aff' => '1', 'ordre' => 1, 'largeur' => 10], + 'recounts' => ['titre' => 'Dépouillements', + 'aff' => '1', + 'ordre' => '190', + 'largeur' => 12], 'avis' => ['titre' => 'avis', 'aff' => '1', 'ordre' => 2, @@ -960,6 +964,108 @@ class RechercheControllerViewNoticeAndResnumeriqueTabAsAdminTest extends Recherc +class RechercheControllerViewNoticeAndRecountsTest extends RechercheControllerNoticeTestCase { + public function setUp() { + parent::setUp(); + Class_Users::getIdentity()->beAdminPortail(); + + $preferences = ['barre_nav' => 'Document', + 'entete' =>"ABCDEFGIKLMNOPRSTtYZ8v9", + 'analytics' => '464', + 'analytics_title' => 'a', + 'analytics_authors' => 'f', + 'onglets' => ['detail' => ['titre' => 'Details', + 'aff' => '1', + 'ordre' => 1, + 'largeur' => 10], + 'recounts' => ['titre' => 'Depouillements', + 'aff' => '1', + 'ordre' => '190', + 'largeur' => 12], + 'avis' => ['titre' => 'avis', + 'aff' => '1', + 'ordre' => 2, + 'largeur' => 10], + 'exemplaires' => ['titre' => 'exemplaires', + 'aff' => '2', + 'ordre' => 3, + 'largeur' => 10], + 'resume' => ['titre' => 'resume', + 'aff' => '2', + 'ordre' => 4, + 'largeur' => 10], + 'tags' => ['titre' => 'tags', + 'aff' => '2', + 'ordre' => 5, + 'largeur' => 10], + 'biographie' => ['titre' => 'biographie', + 'aff' => '2', + 'ordre' => 6, + 'largeur' => 10], + 'similaires' => ['titre' => 'similaires', + 'aff' => '2', + 'ordre' => 7, + 'largeur' => 10], + 'bibliographie' => ['titre' => 'bibliographie', + 'aff' => '3', + 'ordre' => 7, + 'largeur' => 10], + 'morceaux' => ['titre' => 'morceaux', + 'aff' => '3', + 'ordre' => 8, + 'largeur' => 10], + 'bandeAnnonce' => ['titre' => 'bande annonce', + 'aff' => '3', + 'ordre' => 9, + 'largeur' => 10], + 'photos' => ['titre' => 'photos', + 'aff' => '3', + 'ordre' => 14, + 'largeur' => 10], + 'videos' => ['titre' => 'videos', + 'aff' => '3', + 'ordre' => 11, + 'largeur' => 10], + 'resnumeriques' => ['titre' => 'ressources n', + 'aff' => '2', + 'ordre' => 12, + 'largeur' => 10], + 'babeltheque' => ['titre' => 'babeltheque', + 'aff' => '3', + 'ordre' => 13, + 'largeur' => 10], + 'frbr' => ['titre' => 'frbr', + 'aff' => '0', + 'ordre' => 10, + 'largeur' => 10], + 'serie' => ['titre' => 'serie', + 'aff' => '0', + 'ordre' => 11, + 'largeur' => 10]], + 'boite' => null]; + + Class_Profil::beVolatile(); + $this->fixture('Class_Profil', ['id' => 1, + 'libelle' => 'Afibre']) + ->setBarreNavOn(true) + ->setCfgModules(['recherche' => ['viewnotice1' => $preferences]]) + ->beCurrentProfil(); + + $this->fixture('Class_Notice', + ['id' => 12, + 'type_doc' => Class_TypeDoc::LIVRE, + 'unimarc' => '00490nls0 2200193 450 0010003000000050009000030110013000121000041000251010008000661100008000742000026000822070018001082100013001263000041001393260015001804610017001954640050002128010034002629420051221 a12928429 a20051221a20059999m 0fre 0103 0 afre aaga1 aMobiClici21/06/2005 0a74,21/06/2005 d20050621 amagazine de connaissances sur CD-ROM aBimestriel tMobiClicv74 1aUne journée avec les orquesfNior, Annabelle 1aFRbc20051221wBiblixNet 2.0']); + $this->dispatch('recherche/viewnotice/id/12', true); + } + + + /** @test */ + public function recountsTabShouldBePresent() { + $this->assertXpathContentContains('//div//h2', 'Depouillements', $this->_response->getBody()); + } +} + + class RechercheControllerReadNoticeTest extends RechercheControllerNoticeTestCase { public function setUp() { @@ -2902,6 +3008,8 @@ class RechercheControlleSimpleActionWithEmptyDomainSettingsAndArticlesLinkedTest } } + + class RechercheControllerSimpleActionDisableSuggestionTest extends RechercheControllerNoticeTestCase { diff --git a/tests/library/Class/Onglet/AnalyticsItemTest.php b/tests/library/Class/Onglet/AnalyticsItemTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f95bb5aeba5dd8d4437a1f7d72a232ee32a11ba4 --- /dev/null +++ b/tests/library/Class/Onglet/AnalyticsItemTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class Class_Onglet_AnalyticsItemTest extends ModelTestCase { + protected + $_lastname, + $_firstname; + + public function authors() { + return [ + [ 'Truffaut, François' , 'Truffaut', 'François' ], + [ 'Godard, Jean-Luc' , 'Godard', 'Jean-Luc' ], + [ 'Abba' , 'Abba', '' ], + [ 'Kool & Gang' , 'Kool & Gang', '' ], + [ 'Village People' , 'Village People', '' ] + ]; + } + + /** + * @test + * @dataProvider authors + */ + public function authorLabelShouldDecomposeIntoLastNameFirstName($author, $lastname, $firstname) { + $item = new Class_Onglet_AnalyticsItem(); + $item->setTitle('test'); + $item->addAuthor($author); + $item->acceptVisitor($this); + + $this->assertEquals([$lastname, $firstname], [$this->_lastname, $this->_firstname]); + } + + + public function visitAuthor($author) {} + + public function visitAuthorLastNameFirstName($author, $lastname, $firstname) { + $this->_lastname = $lastname; + $this->_firstname = $firstname; + } + + public function visitTitle($title) {} + +} +?> \ No newline at end of file