diff --git a/VERSIONS_HOTLINE/142031 b/VERSIONS_HOTLINE/142031 new file mode 100644 index 0000000000000000000000000000000000000000..49c5f6e67f59ab12cec0a98580886a874f4fc527 --- /dev/null +++ b/VERSIONS_HOTLINE/142031 @@ -0,0 +1 @@ + - ticket #142031 : Administration : Ajout d'un écran de test pour Bokeh. Cette écran est accessible au super administrateur uniquement. \ No newline at end of file diff --git a/application/modules/admin/controllers/IndexController.php b/application/modules/admin/controllers/IndexController.php index 6c739bbff7f556c0da97272f55e9a60f5bf53f0b..4ade7edbdb2d90c8773563869da0c1d92e0e53b8 100644 --- a/application/modules/admin/controllers/IndexController.php +++ b/application/modules/admin/controllers/IndexController.php @@ -176,4 +176,12 @@ class Admin_IndexController extends ZendAfi_Controller_Action { $this->_helper->notify((new Class_Profil_SkinUpdateReader)->cancelClone($this->_getParam('id'))); $this->_redirect('admin/index/update-skin'); } -} \ No newline at end of file + + + public function testMyOpacAction() { + if (!ZendAfi_Auth_Others::getInstance()->isSuperAdminLogged()) + return $this->_redirect('admin/index/index'); + + $this->view->titre = $this->_('Vérifications de base de mon opac'); + } +} diff --git a/application/modules/admin/views/scripts/index/test-my-opac.phtml b/application/modules/admin/views/scripts/index/test-my-opac.phtml new file mode 100644 index 0000000000000000000000000000000000000000..b11eeb50284a3584c7ef346a332cccc0485f0352 --- /dev/null +++ b/application/modules/admin/views/scripts/index/test-my-opac.phtml @@ -0,0 +1,2 @@ +<?php +echo $this->Admin_RenderTestMyOpac(); diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index 74593608322a8702c42b412482e8e0e7fce3ed01..8e39ce9b64e7280c4dc0260a43de7f542592b39d 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -648,6 +648,6 @@ class AuthController extends ZendAfi_Controller_Action { $this->_helper->notify($this->_('Vous êtes maintenant connecté avec l\'utilisateur "%s"', $user->getNomComplet())); - $this->_redirectToUrlOrReferer('/opac/index/index'); + $this->_redirectToUrlOrReferer($this->_getParam('redirect', '/opac/index/index')); } } diff --git a/library/Class/Url.php b/library/Class/Url.php index 8be434eae142cfcc224f06fcf8239ce418c3b829..5455db84f633b434f51b91458f7ac38b9d83d712 100644 --- a/library/Class/Url.php +++ b/library/Class/Url.php @@ -20,6 +20,10 @@ */ class Class_Url { + + const PHP_CLI = 'cli'; + + protected static $_PHP_MODE, $_do_not_add_base_url, @@ -255,7 +259,7 @@ Bokeh Error : adminVar "NOM_DOMAINE" is empty. Bokeh in php cli mode is unable t ? static::$_PHP_MODE : php_sapi_name(); - return 'cli' == $php_mode; + return Class_Url::PHP_CLI == $php_mode; } @@ -264,6 +268,11 @@ Bokeh Error : adminVar "NOM_DOMAINE" is empty. Bokeh in php cli mode is unable t } + public static function getPhpMode() { + return static::$_PHP_MODE; + } + + protected function _siteUrl() { } diff --git a/library/ZendAfi/View/Helper/Admin/ContentNav.php b/library/ZendAfi/View/Helper/Admin/ContentNav.php index c10e51717b808a8bac80344ca0b70fbdb19398d7..6a978af8b96a031e80af02557eab875983ff6d88 100644 --- a/library/ZendAfi/View/Helper/Admin/ContentNav.php +++ b/library/ZendAfi/View/Helper/Admin/ContentNav.php @@ -173,6 +173,7 @@ class ZendAfi_View_Helper_Admin_ContentNav extends ZendAfi_View_Helper_BaseHelpe ['customfields', $this->_('Champs personnalisés'), '/admin/custom-fields/index', [], $is_admin], ['customreports', $this->_('Rapports statistiques'), '/admin/custom-fields-report'], ['variables', $this->_('Journal'), '/admin/journal'], + ['testmyopac', $this->_('Test de mon OPAC'), '/admin/index/test-my-opac', [], $is_super_admin], ]); } diff --git a/library/ZendAfi/View/Helper/Admin/RenderTestMyOpac.php b/library/ZendAfi/View/Helper/Admin/RenderTestMyOpac.php new file mode 100644 index 0000000000000000000000000000000000000000..08cacdbd06500d79528c63454deae5be403fd816 --- /dev/null +++ b/library/ZendAfi/View/Helper/Admin/RenderTestMyOpac.php @@ -0,0 +1,258 @@ +<?php +/** + * Copyright (c) 2012-2021, 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 ZendAfi_View_Helper_Admin_RenderTestMyOpac extends ZendAfi_View_Helper_BaseHelper { + use Trait_Translator; + + + protected static $_search_users_engine; + + + public static function setSearchUsersEngine($engine) { + static::$_search_users_engine = $engine; + } + + + public static function getSearchUsersEngine($params) { + if ( $engine = static::$_search_users_engine) + return $engine; + + return new Class_User_SearchCriteria($params); + } + + + public function Admin_RenderTestMyOpac() { + $php_mode = Class_Url::getPhpMode(); + Class_Url::setPhpMode(Class_URL::PHP_CLI); + $html = $this->view->div(['class' => 'test_my_opac'], + $this->view->tag('ul', + implode($this->_urlsToCheckAsHTML()))); + Class_Url::setPhpMode($php_mode); + return $html; + } + + + protected function _urlsToCheckAsHTML() { + $urls = new Storm_Collection; + $this + ->_addCommonsUrls($urls) + ->_addRecordsUrls($urls) + ->_addAuthorsUrls($urls) + ->_addUsersUrls($urls) + ->_addProfilesUrls($urls) + ->_addLibrariesUrls($urls); + + return $urls + ->injectInto([], + function($html, $instance) + { + $html [] = $this->_renderUrl($instance); + return $html; + }); + } + + + protected function _constructUrl($attribs) { + return $this->view->url(array_merge(['module' => 'opac'], + $attribs), + null, true); + } + + + protected function _addCommonsUrls($collection) { + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'index', + 'action' => 'index', + 'id_profil' => 1])) + + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'simple', + 'expressionRecherche' => 'pomme'])) + + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'recherche', + 'action' => 'avancee'])); + + return $this; + } + + + protected function _addRecordsUrls($collection) { + $type_docs = [Class_TypeDoc::LIVRE, + Class_TypeDoc::PERIODIQUE, + Class_TypeDoc::DISQUE, + Class_TypeDoc::DVD, + Class_TypeDoc::ARTICLE]; + + foreach ($type_docs as $doctype_id) + if ($record = Class_Notice::findFirstBy(['type_doc' => $doctype_id])) + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl($this->view->urlNotice($record))); + return $this; + } + + + protected function _addAuthorsUrls($collection) { + if ( ! $authors = Class_CodifAuteur::findAllBy(['id_auteur not' => '', + 'limit' => 2])) + return $this; + + foreach ( $authors as $author ) + $collection->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'author', + 'action' => 'view', + 'id' => $author->getId()])); + return $this; + } + + + protected function _addUsersUrls($collection) { + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'abonne', + 'action' => 'fiche', + 'id' => Class_Users::getIdentity()->getId()])); + + $search = static::getSearchUsersEngine(['search_role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'search_valid_subscription' => 1, + 'search_review' => 1]); + + $result = $search->findPage(); + + if ( ! $borrower = array_shift($result) ) + return $this; + + $borrower_url = $this->view->url(['module' => 'opac', + 'controller' => 'abonne', + 'action' => 'fiche', + 'id' => $borrower->getId()], + null, + true); + + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'auth', + 'action' => 'become', + 'id' => $borrower->getId(), + 'redirect' => $borrower_url])); + + return $this; + } + + + protected function _addProfilesUrls($collection) { + if ( ! $agenda = Class_Profil::findFirstBy(['rewrite_url' => 'agenda'])) + return $this; + + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(Class_Url::relative($agenda->getUrlParts()))); + + return $this; + } + + + protected function _addLibrariesUrls($collection) { + if ( $library_with_rewrite_url = Class_Bib::findFirstBy(['rewrite_url not' => ''])) + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(Class_Url::relative(['module' => $library_with_rewrite_url->getRewriteUrl()]))); + + if (Class_Template::current()->isLegacy()) + return $this; + + if ( ! $library = Class_Bib::findFirstBy([])) + return $this; + + $collection + ->add((new ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl) + ->setUrl(['module' => 'opac', + 'controller' => 'bib', + 'action' => 'en-lire-plus', + 'id' => $library->getId()])); + + return $this; + } + + + protected function _renderUrl($instance) { + $url = is_array($instance->getUrl()) + ? Class_Url::relative($instance->getUrl(), null, true) + : $instance->getUrl(); + + $url_prod = str_replace('http:', 'https:', Class_Url::absolute($instance->getUrl(), null, true)); + + $id = md5($url); + $this->_addJS($id, $url); + + return $this->view->tag('li', + $this->view->tag('span', + '', + ['id' => $id, + 'class' => 'http_status']) + . $this->view->tagAnchor($url, + $url, + ['title' => $this->_('Lien vers %s', $url)]) + . $this->view->tagAnchor($url_prod, + $url_prod, + ['title' => $this->_('Lien vers %s', $url_prod)])); + } + + + protected function _addJS($id, $url) { + if (strpos($url, 'auth/become')) + return; + + $fct_js = sprintf('{ complete: function (xhr, status) { "success" == status ? $("#%s").addClass("success") : $("#%s").addClass("error"); } }', + $id, $id); + $js = sprintf('$.ajax("%s", %s)', $url, $fct_js); + Class_ScriptLoader::getInstance()->addJQueryReady($js); + } +} + + + + +class ZendAfi_View_Helper_Admin_RenderTestMyOpacUrl { + + protected $_url; + + + public function setUrl($url) { + $this->_url = $url; + return $this; + } + + + public function getUrl() { + return $this->_url; + } +} \ No newline at end of file diff --git a/public/admin/css/global.css b/public/admin/css/global.css index 7d929b9941087513468b0fda76b05dad8fd8bb3b..e66a3320a651f7a564480ce8d3395b7dff070681 100644 --- a/public/admin/css/global.css +++ b/public/admin/css/global.css @@ -67,8 +67,8 @@ li.selected {font-weight: bold;} /* Form */ -.required:after { - content:" *"; +.required:after { + content:" *"; color: red; } @@ -364,7 +364,7 @@ div#permalink { .modules .survol:hover{background-color:#78AEFF;font-size:10pt;} .modules .separ{max-height:1px;height:1px;padding:0px;background-color:#A0A0A0;} .modules a {color:#0058A5;text-decoration:none;} -.modules .avis-cms td a { padding: 0px 5px;} +.modules .avis-cms td a { padding: 0px 5px;} .modules a:hover {color:#0058A5;text-decoration:underline;} .modules a:visited {} .modules img.ico {width:16px;height:16px;border:none;} @@ -1041,7 +1041,7 @@ form#import_ead dl { .tree .album>div:first-child + div { max-width: 500px; -} +} @@ -1221,7 +1221,7 @@ span.ui-dialog-title { color:#0058A5; width: 350px; text-align:center; -} +} #opac-dialog dl dt { float:left; @@ -1254,7 +1254,7 @@ span.ui-dialog-title { background: url(../images/patience.gif) no-repeat top left; } -#suggestions { +#suggestions { table-layout: fixed; } @@ -1520,7 +1520,7 @@ a[class^="edit_"] { } div.ColorPickerDivSample { - margin-top: 4px; + margin-top: 4px; margin-right: 0px; } @@ -1681,3 +1681,47 @@ table#logs img { overflow: auto; max-height: 300px; } + +.test_my_opac .http_status { + display: inline-block; + height: 1em; + width: 1em; + border-radius: 30px; + margin-right: 5px; + background-color: var(--button-disabled); +} + +.test_my_opac .http_status.success { + background-color: var(--success-background); +} + +.test_my_opac .http_status.error { + background-color: var(--error-background); +} + +.test_my_opac li { + padding: 5px 0; + margin: 10px 0; + border-bottom: 1px solid; + border-color: var(--separator); +} + +.test_my_opac a:first-of-type { + width: 350px; +} + +.test_my_opac a { + max-width: 350px; + overflow: hidden; + display: inline-block; + white-space: nowrap; + text-overflow: ellipsis; +} + +.test_my_opac a + a { + margin-left: 50px; +} + +.test_my_opac li:hover { + background-color: var(--line-highlight); +} diff --git a/public/admin/skins/bokeh72/config.json b/public/admin/skins/bokeh72/config.json index fc165ddf0473a110f1b36d8289f27ea115731494..985cad96e821b6bbd30afe3cea4062d03f42f18c 100644 --- a/public/admin/skins/bokeh72/config.json +++ b/public/admin/skins/bokeh72/config.json @@ -57,6 +57,7 @@ "doctypes": "../../images/picto/type_docs_16.png", "thesaurus_init": "../../images/picto/generation_16.png", "thesaurus_edit": "../../images/picto/generation_16.png", + "testmyopac": "icons/menu/link_24.png", "home": "../../images/picto/icon_home.gif", "back_to_front": "../../images/picto/profils_16.png", diff --git a/public/admin/skins/bokeh74/config.json b/public/admin/skins/bokeh74/config.json index 15f4733bbca3648f3de91558bbd5ec31057ba23b..46017cdd2643b7292945bd0f8f58116bdda79099 100644 --- a/public/admin/skins/bokeh74/config.json +++ b/public/admin/skins/bokeh74/config.json @@ -1,6 +1,6 @@ { "icons": - { + { "articles":"icons/menu/articles_24.png", "domains":"icons/menu/domaines_24.png", "rss":"icons/menu/rss_24.png", @@ -47,6 +47,7 @@ "thesaurus_edit": "icons/menu/import_thesaurus_24.png", "filebrowser": "icons/menu/file_browser_24.png", "cosmogramme": "icons/menu/database_24.png", + "testmyopac": "icons/menu/link_24.png", "artevod": "../../images/picto/artevod_16.png", "vodeclic": "../../images/picto/vodeclic_16.png", diff --git a/public/admin/skins/bokeh74/global.css b/public/admin/skins/bokeh74/global.css index b07a7f20c2e2ac1462dfa32ed7f4adce65b5730d..1a049473b38cb665f3d3b6d67b532b3bc569058e 100755 --- a/public/admin/skins/bokeh74/global.css +++ b/public/admin/skins/bokeh74/global.css @@ -1075,3 +1075,47 @@ table#album_item th, table#album_usage_report th { .modo_index .critique .contenu_critique .note_critique { display: block; } + +.test_my_opac .http_status { + display: inline-block; + height: 1em; + width: 1em; + border-radius: 30px; + margin-right: 5px; + background-color: var(--button-disabled); +} + +.test_my_opac .http_status.success { + background-color: var(--success-background); +} + +.test_my_opac .http_status.error { + background-color: var(--error-background); +} + +.test_my_opac li { + padding: 5px 0; + margin: 10px 0; + border-bottom: 1px solid; + border-color: var(--separator); +} + +.test_my_opac a:first-of-type { + width: 350px; +} + +.test_my_opac a { + max-width: 350px; + overflow: hidden; + display: inline-block; + white-space: nowrap; + text-overflow: ellipsis; +} + +.test_my_opac a + a { + margin-left: 50px; +} + +.test_my_opac li:hover { + background-color: var(--line-highlight); +} diff --git a/public/admin/skins/noel/config.json b/public/admin/skins/noel/config.json index ce45549444fd15e70dab9ac680d0f6e5844ea0c6..a4bd1988adc7055df4e73932a9ab0b2294380cea 100644 --- a/public/admin/skins/noel/config.json +++ b/public/admin/skins/noel/config.json @@ -47,6 +47,7 @@ "thesaurus_edit": "icons/menu/import_thesaurus_24.png", "filebrowser": "icons/menu/file_browser_24.png", "cosmogramme": "icons/menu/database_24.png", + "testmyopac": "icons/menu/link_24.png", "artevod": "../../images/picto/artevod_16.png", "vodeclic": "../../images/picto/vodeclic_16.png", diff --git a/public/admin/skins/retro/config.json b/public/admin/skins/retro/config.json index 91889c2c808c2a7552bd5a72664bcd2fb4d7da21..3fbb30d1640972e29920c81123042d208e856580 100644 --- a/public/admin/skins/retro/config.json +++ b/public/admin/skins/retro/config.json @@ -47,7 +47,8 @@ "thesaurus_edit": "icons/menu/import_thesaurus_24.png", "filebrowser": "icons/menu/file_browser_24.png", "cosmogramme": "icons/menu/database_24.png", - + "testmyopac": "icons/menu/link_24.png", + "artevod": "../../images/picto/artevod_16.png", "vodeclic": "../../images/picto/vodeclic_16.png", "orphea": "../../images/picto/orphea_16.png", diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php index a7e03381c109d53b2a34fafed4056d090da33ad2..5f31a81f99d8bd193c7b29a09764f7c622bbb7bc 100644 --- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php @@ -39,11 +39,12 @@ abstract class AdminIndexControllerTestCase extends Admin_AbstractControllerTest class AdminIndexControllerIndexActionTest extends AdminIndexControllerTestCase { + public function setUp() { parent::setUp(); - $this->fixture('Class_AdminVar', ['id' => 'LANGUES', 'valeur' => '']); - $this->dispatch('/admin/index', true); + $this->fixture(Class_AdminVar::class, ['id' => 'LANGUES', 'valeur' => '']); + $this->dispatch('/admin/index'); } @@ -67,7 +68,7 @@ class AdminIndexControllerIndexActionTest extends AdminIndexControllerTestCase { /** @test */ public function helpLinkShouldBePresent() { - $this->assertXPath("//a[@href='http://wiki.bokeh-library-portal.org/index.php/Bokeh']//img", $this->_response->getBody()); + $this->assertXPath("//a[@href='http://wiki.bokeh-library-portal.org/index.php/Bokeh']//img"); } @@ -79,7 +80,13 @@ class AdminIndexControllerIndexActionTest extends AdminIndexControllerTestCase { /** @test */ public function menuGaucheShouldContainsCustomFields() { - $this->assertXPathContentContains('//li//a','Champs personnalisés'); + $this->assertXPathContentContains('//li//a', 'Champs personnalisés'); + } + + + /** @test */ + public function menuGaucheShouldContainsTestMyOpac() { + $this->assertXPathContentContains('//li//a', 'Test de mon OPAC'); } } @@ -981,4 +988,4 @@ class AdminIndexControllerWithFormLinkTest extends Admin_AbstractControllerTestC $this->dispatch('admin/index'); $this->assertXPathContentContains('//div[@class = "ligne_info "]', 'Base de donnée'); } -} \ No newline at end of file +} diff --git a/tests/application/modules/admin/controllers/IndexControllerTest.php b/tests/application/modules/admin/controllers/IndexControllerTest.php index 01b38a31ccfa0d75923d99b2bf9e11648c9781bc..bd899537a5a6e48c2f4291f0006463a8d16814ee 100644 --- a/tests/application/modules/admin/controllers/IndexControllerTest.php +++ b/tests/application/modules/admin/controllers/IndexControllerTest.php @@ -638,3 +638,275 @@ class Admin_IndexControllerAdminvareditTest extends Admin_AbstractControllerTest $this->assertXPath('//form//div[@id="multi_inputs_valeur"]'); } } + + + + +class Admin_IndexControllerDispatchWithAllFixturesMyOpacTest + extends Admin_AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('NOM_DOMAINE', 'ma_mediatheque.fr'); + + $this->_buildTemplateProfil(['id' => 11, + 'libelle' => 'MT template', + 'template' => 'MUSCLE']); + + $this->fixture(Class_Notice::class, + ['id' => 111, + 'type_doc' => Class_TypeDoc::LIVRE, + 'clef_alpha' => 'TROLLSDETROY']); + + $this->fixture(Class_Notice::class, + ['id' => 112, + 'type_doc' => Class_TypeDoc::PERIODIQUE, + 'clef_alpha' => 'FEMMEACTUELLE']); + + $this->fixture(Class_Notice::class, + ['id' => 113, + 'type_doc' => Class_TypeDoc::DISQUE, + 'clef_alpha' => 'ROCK']); + + $this->fixture(Class_Notice::class, + ['id' => 114, + 'type_doc' => Class_TypeDoc::DVD, + 'clef_alpha' => 'TERMINATOR']); + + $this->fixture(Class_Notice::class, + ['id' => 115, + 'type_doc' => Class_TypeDoc::ARTICLE, + 'clef_alpha' => 'NOEL']) + ->set_subfield('856', 'b', 12312); + + $this->fixture(Class_CodifAuteur::class, + ['id' => 222]); + + $this->fixture(Class_CodifAuteur::class, + ['id' => 223]); + + $borrower = $this->fixture(Class_Users::class, + ['id' => 789, + 'login' => 'borrower', + 'password' => 'hidden', + 'idabon' => '123', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1]); + + $search_users_engine = $this + ->mock() + + ->whenCalled('findPage') + ->answers([$borrower]); + + ZendAfi_View_Helper_Admin_RenderTestMyOpac::setSearchUsersEngine($search_users_engine); + + $this->fixture(Class_Profil::class, + ['id' => 89, + 'rewrite_url' => 'agenda']); + + $this->fixture(Class_Bib::class, + ['id' => 442]); + + $this->fixture(Class_Bib::class, + ['id' => 443, + 'rewrite_url' => 'ma-super-mediatheque']); + + $this->dispatch('/admin/index/test-my-opac'); + } + + + public function tearDown() { + ZendAfi_View_Helper_Admin_RenderTestMyOpac::setSearchUsersEngine(null); + parent::tearDown(); + } + + + public function urlToDispatch() { + return [ + ['/index/index/id_profil/1', + 'ma_mediatheque.fr/index/index/id_profil/1'], + + ['/recherche/simple/expressionRecherche/pomme', + 'ma_mediatheque.fr/recherche/simple/expressionRecherche/pomme'], + + ['/recherche/avancee', + 'ma_mediatheque.fr/recherche/avancee'], + + ['/recherche/viewnotice/clef/FEMMEACTUELLE/id/112', + 'ma_mediatheque.fr/recherche/viewnotice/clef/FEMMEACTUELLE/id/112'], + + ['/recherche/viewnotice/clef/TROLLSDETROY/id/111', + 'ma_mediatheque.fr/recherche/viewnotice/clef/TROLLSDETROY/id/111'], + + ['/recherche/viewnotice/clef/ROCK/id/113', + 'ma_mediatheque.fr/recherche/viewnotice/clef/ROCK/id/113'], + + ['/recherche/viewnotice/clef/TERMINATOR/id/114', + 'ma_mediatheque.fr/recherche/viewnotice/clef/TERMINATOR/id/114'], + + ['/cms/articleview/id/12312', + 'ma_mediatheque.fr/cms/articleview/id/12312'], + + ['/author/view/id/222', + 'ma_mediatheque.fr/author/view/id/222'], + + ['/author/view/id/223', + 'ma_mediatheque.fr/author/view/id/223'], + + ['/abonne/fiche/id/666', + 'ma_mediatheque.fr/abonne/fiche/id/666'], + + ['/auth/become/id/789/redirect/%2Fabonne%2Ffiche%2Fid%2F789', + 'ma_mediatheque.fr/auth/become/id/789/redirect/%2Fabonne%2Ffiche%2Fid%2F789', + false], + + ['/agenda', + 'ma_mediatheque.fr/agenda'], + + ['/ma-super-mediatheque', + 'ma_mediatheque.fr/ma-super-mediatheque'], + + ['/bib/en-lire-plus/id/442', + 'ma_mediatheque.fr/bib/en-lire-plus/id/442'], + + ]; + } + + + /** + * @test + * @dataProvider urlToDispatch + */ + public function linkToUrlsShouldBeRespected($local_url, $prod_url) { + $this->assertXPath('//div[@class="modules"]//div[@class="test_my_opac"]/ul/li/a[contains(@href, "' . $local_url . '")][contains(text(),"' . $local_url . '")][following-sibling::a[contains(@href, "' . $prod_url . '")][contains(text(), "' . $prod_url . '")]]'); + } + + + /** + * @test + * @dataProvider urlToDispatch + */ + public function loadToUrlsShouldBeRespected($url, $prod_url, $script = true) { + if ($script) + $this->assertXPathContentContains('//script[contains(text(), "$.ajax")]', $url); + } + + + + /** @test */ + public function fifteenLinksShouldBePresent() { + $this->assertXPathCount(15, '//div[@class="modules"]//div[@class="test_my_opac"]/ul/li/a'); + } +} + + + + +class IndexControllerTestMyOpacForModoPortailTest extends AbstractControllerTestCase { + + protected function _loginHook($account) { + $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL; + } + + + /** @test */ + public function testMyOpacShouldNotBeAccessible() { + $this->dispatch('admin/index/test-my-opac'); + $this->assertRedirect(); + } +} + + + + +class IndexControllerTestMyOpacForAdminPortailTest + extends AbstractControllerTestCase { + + protected function _loginHook($account) { + $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL; + } + + + /** @test */ + public function testMyOpacShouldNotBeAccessible() { + $this->dispatch('admin/index/test-my-opac'); + $this->assertRedirect(); + } +} + + + + +class IndexControllerTestMyOpacForSuperAdminTest + extends AbstractControllerTestCase { + + protected function _loginHook($account) { + $account->ROLE_LEVEL = ZendAfi_Acl_AdminControllerRoles::SUPER_ADMIN; + } + + + /** @test */ + public function testMyOpacShouldBeAccessible() { + $this->dispatch('admin/index/test-my-opac'); + $this->assertNotRedirect(); + } +} + + + + + +class Admin_IndexControllerDispatchWithNoFixturesMyOpacTest extends Admin_AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + + public function setUp() { + parent::setUp(); + + Class_AdminVar::set('NOM_DOMAINE', 'ma_mediatheque.fr'); + + $this->_buildTemplateProfil(['id' => 11, + 'libelle' => 'MT template', + 'template' => 'MUSCLE']); + + $this->dispatch('/admin/index/test-my-opac'); + } + + + public function tearDown() { + ZendAfi_View_Helper_Admin_RenderTestMyOpac::setSearchUsersEngine(null); + parent::tearDown(); + } + + + public function urlToDispatch() { + return [['/index/index/id_profil/1', + 'ma_mediatheque.fr/index/index/id_profil/1'], + + ['/recherche/simple/expressionRecherche/pomme', + 'ma_mediatheque.fr/recherche/simple/expressionRecherche/pomme'], + + ['/recherche/avancee', + 'ma_mediatheque.fr/recherche/avancee']]; + } + + + /** + * @test + * @dataProvider urlToDispatch + */ + public function linkToUrlsShouldBeRespected($local_url, $prod_url) { + $this->assertXPath('//div[@class="modules"]//div[@class="test_my_opac"]/ul/li/a[contains(@href, "' . $local_url . '")][contains(text(),"' . $local_url . '")][following-sibling::a[contains(@href, "' . $prod_url . '")][contains(text(), "' . $prod_url . '")]]'); + } + + + /** @test */ + public function threeLinksShouldBePresent() { + $this->assertXPathCount(3, '//div[@class="modules"]//div[@class="test_my_opac"]/ul/li/a'); + } +} \ No newline at end of file diff --git a/tests/scenarios/Become/BecomeTest.php b/tests/scenarios/Become/BecomeTest.php index a33fbb2d4b7f0e884c6f80d03c46f7ac050700ab..758cf4fbc14cabacb71e56481231a3903cecdc5c 100644 --- a/tests/scenarios/Become/BecomeTest.php +++ b/tests/scenarios/Become/BecomeTest.php @@ -275,4 +275,39 @@ class BecomeUsersControllerWithSuperAdminTest extends Admin_AbstractControllerTe public function linkToBecomeTimShouldBePresent() { $this->assertXPath('//a[contains(@href, "/auth/become/")]', $this->_response->getBody()); } -} \ No newline at end of file +} + + + + +class BecomeUserAndRedirectToAbonneFicheTest + extends Admin_AbstractControllerTestCase { + + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + $this->fixture(Class_Users::class, + ['id' => 222, + 'login' => 'Pauline', + 'password' => 'pwd2', + 'idabon' => '1234', + 'id_site' => 1, + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]); + + $this->dispatch('/opac/auth/become/id/222/redirect/%2Fabonne%2Ffiche%2Fid%2F222'); + } + + + /** @test */ + public function shouldRedirectToAbonneFiche222() { + $this->assertRedirectContains('/abonne/fiche/id/222'); + } + + + /** @test */ + public function logedUserShouldBeTest222() { + $this->assertEquals(222, Class_Users::getIdentity()->getId()); + } +}