diff --git a/library/ZendAfi/View/Helper/Admin/ContentNav.php b/library/ZendAfi/View/Helper/Admin/ContentNav.php index 3a9de050e26f057cea68235e87bf9c594d843fe1..ea1d6c10e3c6788606ade9e57f42bb3ecc51552b 100644 --- a/library/ZendAfi/View/Helper/Admin/ContentNav.php +++ b/library/ZendAfi/View/Helper/Admin/ContentNav.php @@ -142,7 +142,7 @@ class ZendAfi_View_Helper_Admin_ContentNav extends ZendAfi_View_Helper_BaseHelpe ['links', $this->_('Contrôle des URL'), '/admin/url-manager'], ['variables', $this->_('Variables'), '/admin/index/adminvar', [], $is_admin], - ['webservice_tests', $this->_('Test des web-services'), '/admin/systeme/webservices'], + ['webservice_tests', $this->_('Test des web-services'), '/admin/systeme/webservices', [], $is_super_admin], ['sendmail_tests', $this->_('Test envoi mails'), '/admin/systeme/mailtest', [], $is_super_admin], ['php', $this->_('Informations système'), '/admin/systeme/phpinfo', [], $is_super_admin], @@ -211,91 +211,3 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminBloc { ['class' => 'menuGaucheAdmin']); } } - - - -class ZendAfi_View_Helper_Admin_MenuGaucheAdminItem { - protected static $_acl; - - protected - $_icon, - $_title, - $_url, - $_attribs, - $_skin; - - - public static function newWith($params) { - return new static($params[0], - $params[1], - $params[2], - isset($params[3]) ? $params[3] : [], - isset($params[4]) ? $params[4] : null); - } - - - public function __construct($icon, $title, $url, $attribs=[], $filter=null) { - $this->_icon = $icon; - $this->_title = $title; - $this->_url = $url; - $this->_attribs = $attribs; - $this->_filter = $filter; - $this->_skin = Class_Admin_Skin::current(); - } - - - public function renderFor($user, $view) { - if (!$this->_isAllowed($user)) - return ''; - - $url = $this->_url; - if('http' != substr($url, 0, 4)) - $url = BASE_URL . $url; - - $extra_infos = isset($this->_attribs['extra_infos']) - ? $view->tag('span', $this->_attribs['extra_infos'], ['class' => 'menu_info']) - : ''; - - $attributes = (array_key_exists('REQUEST_URI', $_SERVER) - && false !== strpos($_SERVER['REQUEST_URI'], $url)) - ? ['class' => 'selected'] - : []; - - $anchor_params = ['href' => $url]; - if (isset($this->_attribs['target'])) - $anchor_params['target'] = $this->_attribs['target']; - - $ico = $this->_skin->renderMenuIconOn($this->_icon, $view, ['alt' => $this->_title]); - - return $view->tag('li', - $view->tag('a', $ico . $this->_title, $anchor_params) . $extra_infos, - $attributes); - } - - - protected function _isAllowed($user) { - if (($filter = $this->_filter) && !$filter($user)) - return false; - - if ('/admin/' != substr($this->_url, 0, 7)) - return true; - - $url = substr($this->_url, 7); - $parts = explode('/', $url); - - return $this->getAcl()->isAllowed($user, $parts[0], isset($parts[1]) ? $parts[1] : ''); - } - - - /** @category testing */ - public static function setAcl($acl) { - static::$_acl = $acl; - } - - - protected function getAcl() { - return static::$_acl - ? static::$_acl - : static::$_acl = new ZendAfi_Acl_AdminControllerGroup(); - } -} diff --git a/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminItem.php b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminItem.php new file mode 100644 index 0000000000000000000000000000000000000000..76020eb755c4dd20bb6ec842c4db781ee600db8c --- /dev/null +++ b/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminItem.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright (c) 2012-2019, 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_MenuGaucheAdminItem { + protected static $_acl; + + protected + $_icon, + $_title, + $_url, + $_attribs, + $_skin; + + + public static function newWith($params) { + return new static($params[0], + $params[1], + $params[2], + isset($params[3]) ? $params[3] : [], + isset($params[4]) ? $params[4] : null); + } + + + public function __construct($icon, $title, $url, $attribs=[], $filter=null) { + $this->_icon = $icon; + $this->_title = $title; + $this->_url = $url; + $this->_attribs = $attribs; + $this->_filter = $filter; + $this->_skin = Class_Admin_Skin::current(); + } + + + public function renderFor($user, $view) { + if (!$this->_isAllowed($user)) + return ''; + + $url = $this->_url; + if('http' != substr($url, 0, 4)) + $url = BASE_URL . $url; + + $extra_infos = isset($this->_attribs['extra_infos']) + ? $view->tag('span', $this->_attribs['extra_infos'], ['class' => 'menu_info']) + : ''; + + $attributes = (array_key_exists('REQUEST_URI', $_SERVER) + && false !== strpos($_SERVER['REQUEST_URI'], $url)) + ? ['class' => 'selected'] + : []; + + $anchor_params = ['href' => $url]; + if (isset($this->_attribs['target'])) + $anchor_params['target'] = $this->_attribs['target']; + + $ico = $this->_skin->renderMenuIconOn($this->_icon, $view, ['alt' => $this->_title]); + + return $view->tag('li', + $view->tag('a', $ico . $this->_title, $anchor_params) . $extra_infos, + $attributes); + } + + + protected function _isAllowed($user) { + if (($filter = $this->_filter) && !$filter($user)) + return false; + + if ('/admin/' != substr($this->_url, 0, 7)) + return true; + + $url = substr($this->_url, 7); + $parts = explode('/', $url); + + return $this->getAcl()->isAllowed($user, $parts[0], isset($parts[1]) ? $parts[1] : ''); + } + + + /** @category testing */ + public static function setAcl($acl) { + static::$_acl = $acl; + } + + + protected function getAcl() { + return static::$_acl + ? static::$_acl + : static::$_acl = new ZendAfi_Acl_AdminControllerGroup(); + } +} diff --git a/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php b/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php index f30bfe8617bfc4b218b409ad68b3b7c803672296..64ef5ff067d3e0d9b1d54f1d9549c91d37b9c62c 100644 --- a/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php +++ b/tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php @@ -31,5 +31,10 @@ abstract class Admin_AbstractControllerTestCase extends AbstractControllerTestCa $account->LOGIN = "sysadmin"; $account->PSEUDO = "admin"; } + + + public function tearDown() { + ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); + parent::tearDown(); + } } -?> \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php index b39c7077e15b650b8350b3c504ac07d2db85fcb9..23a09001d62c1aee5155d067e86873f255bd1454 100644 --- a/tests/application/modules/admin/controllers/AdminIndexControllerTest.php +++ b/tests/application/modules/admin/controllers/AdminIndexControllerTest.php @@ -81,12 +81,6 @@ class AdminIndexControllerIndexActionTest extends AdminIndexControllerTestCase { public function menuGaucheShouldContainsCustomFields() { $this->assertXPathContentContains('//li//a','Champs personnalisés'); } - - - /** @test */ - public function menuGaucheShouldContainsCustomFieldReport() { - $this->assertXPathContentContains('//li//a','Rapports statistiques'); - } } diff --git a/tests/application/modules/admin/controllers/AlbumControllerTest.php b/tests/application/modules/admin/controllers/AlbumControllerTest.php index 35287033343e91cc5a117ad19dce2d11b1192d48..c31ce32943db5f891790aa1e3f426f44b125e6bd 100644 --- a/tests/application/modules/admin/controllers/AlbumControllerTest.php +++ b/tests/application/modules/admin/controllers/AlbumControllerTest.php @@ -42,9 +42,9 @@ abstract class Admin_AlbumControllerTestCase extends Admin_AbstractControllerTes $fre = $langue_loader->newInstanceWithId('fre')->setLibelle('français'); $dak = $langue_loader->newInstanceWithId('dak')->setLibelle('dakota'); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifLangue') - ->whenCalled('findAllBy') - ->answers(array($cus, $fre, $dak)); + $this->onLoaderOfModel('Class_CodifLangue') + ->whenCalled('findAllBy') + ->answers([$cus, $fre, $dak]); $favoris = $this->fixture('Class_AlbumCategorie', ['id' => 2]) ->setParentId(0) diff --git a/tests/application/modules/admin/controllers/ProfilControllerTest.php b/tests/application/modules/admin/controllers/ProfilControllerTest.php index d4c6642b22b56fbacc43a8fe9844531c90751e23..6b201a6be244c71fb5cf96010c5c08e59586167d 100644 --- a/tests/application/modules/admin/controllers/ProfilControllerTest.php +++ b/tests/application/modules/admin/controllers/ProfilControllerTest.php @@ -1357,17 +1357,19 @@ class Admin_ProfilControllerNonExistingProfileTest extends Admin_AbstractControl class Admin_ProfilControllerGenresActionTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); + Class_AdminVar::set('CUSTOM_GENRE_ICON', 1); + $this->dispatch('/admin/profil/genres'); } /** @test */ - function actionShouldBeGenres() { + public function actionShouldBeGenres() { $this->assertAction('genres'); } - } + class Admin_ProfilControllerEditMenuHorizontalTest extends Admin_AbstractControllerTestCase { public function setUp() { parent::setUp(); diff --git a/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php b/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php index 8df217220e728e80c0ca0f0aa9518aa79d270c76..c91cb8c5cdc770063b7aea7454528f8223122be8 100644 --- a/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php +++ b/tests/application/modules/admin/controllers/ReferentPortailControllerTest.php @@ -1,4 +1,4 @@ -<?php +b<?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * @@ -16,12 +16,13 @@ * * 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 */ require_once 'AbstractControllerTestCase.php'; -abstract class ReferentPortailController_AbstractControllerTestCase extends AbstractControllerTestCase { - use Trait_UserGroupFixtures; +abstract class ReferentPortailControllerTestCase extends AbstractControllerTestCase { + use Trait_UserGroupFixtures; + protected function _initProfilHook($profil) { $profil->setLibelle('AFI'); } @@ -36,10 +37,10 @@ abstract class ReferentPortailController_AbstractControllerTestCase extends Abst public function setUp() { parent::setUp(); $user_referent=Class_Users::getLoader()->newInstanceWithId(777) - ->setLogin('referent') - ->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL) - ->setPseudo('referent'); - + ->setLogin('referent') + ->setRoleLevel(ZendAfi_Acl_AdminControllerRoles::MODO_PORTAIL) + ->setPseudo('referent'); + $this->addUserToRightsReferent($user_referent); } @@ -47,39 +48,42 @@ abstract class ReferentPortailController_AbstractControllerTestCase extends Abst -class ReferentPortailControllerIndexActionTest extends ReferentPortailController_AbstractControllerTestCase { +class ReferentPortailControllerIndexActionTest extends ReferentPortailControllerTestCase { public function setUp() { parent::setUp(); - Class_AdminVar::getLoader()->newInstanceWithId('BIBNUM') - ->setValeur(1); + + Class_AdminVar::set('BIBNUM', 1); + Class_AdminVar::set('OPDS', 1); + $this->dispatch('/admin/index', true); } + /** @test */ function menuGaucheShouldContainsSitotheque() { $this->assertXPathContentContains('//li//a','Sitothèque',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsDomaines() { $this->assertXPathContentContains('//li//a','Domaines',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsModeration() { $this->assertXPathContentContains('//li//a','Modération',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsDemandeDinscription() { $this->assertXPathContentContains('//li//a','Demandes d\'inscription',$this->_response->getBody()); } - /** @test */ + /** @test */ function menuGaucheShouldContainsCollections() { $this->assertXPathContentContains('//li//a','Collections',$this->_response->getBody()); } @@ -99,8 +103,4 @@ class ReferentPortailControllerIndexActionTest extends ReferentPortailController function menuGaucheShouldContainsUtilisateurs() { $this->assertXPathContentContains('//li//a','Utilisateurs',$this->_response->getBody()); } - - -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php b/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php index b81b0e4aff3b49b100e7589b2dd060824957a7c4..64c32e9924bbfe346f4bc2191d0c820a1425a602 100644 --- a/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php +++ b/tests/library/ZendAfi/View/Helper/Admin/MenuGaucheAdminTest.php @@ -35,6 +35,8 @@ abstract class ZendAfi_View_Helper_Admin_MenuGaucheAdminTestCase extends ViewHel $this->helper->setView($this->view); ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); + Class_AdminVar::set('OPDS', 1); + Class_AdminVar::set('BIBNUM', 1); $this->html = $this->helper->Admin_ContentNav(); } @@ -60,7 +62,6 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminVariableAsAdminTest public function _prepareFixtures() { parent::_prepareFixtures(); - $this->login(ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL); RessourcesNumeriquesFixtures::activateOrphea(); RessourcesNumeriquesFixtures::deactivateDilicom(); @@ -354,10 +355,20 @@ class ZendAfi_View_Helper_Admin_MenuGaucheAdminRightsTest extends ViewHelperTest $this->helper = new ZendAfi_View_Helper_Admin_ContentNav(); $this->helper->setView($this->view); ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); + Class_AdminVar::set('ACTIVITY', 1); Class_AdminVar::set('BIBNUM', 1); Class_AdminVar::set('SITO_IN_ALBUMS', 1); Class_AdminVar::set('CODIFICATION_BROWSER', 1); + Class_AdminVar::set('OAI_REPOSITORY', 1); + Class_AdminVar::set('CUSTOM_GENRE_ICON', 1); + Class_AdminVar::set('WEBSERVICE_TEST', 1); + Class_AdminVar::set('IMPORT_AVIS_OPAC2', 1); + Class_AdminVar::set('GENERATION_SITE', 1); + Class_AdminVar::set('CUSTOM_FIELDS_REPORT', 1); + Class_AdminVar::set('IMPORT_THESAURUS', 1); + Class_AdminVar::set('IMPORT_EAD', 1); + } diff --git a/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php b/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php index ae828b91d92eca5e8f82443b34d8dc4512028071..252cc063c5de409862d6ecbdfc52a8b6db5179fc 100644 --- a/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php +++ b/tests/scenarios/AdvancedSearch/AdminConfigurationTest.php @@ -20,7 +20,7 @@ */ -class AdvancedSearch_AdminConfigurationUnactiveTest extends Admin_AbstractControllerTestCase { +class AdvancedSearch_AdminConfigurationUnactiveTest extends Admin_AbstractControllerTestCase { protected $_storm_default_to_volatile = true; public function setUp() { @@ -29,12 +29,6 @@ class AdvancedSearch_AdminConfigurationUnactiveTest extends Admin_AbstractCont } - public function tearDown() { - ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); - parent::tearDown(); - } - - /** @test */ public function menuAdvancedFormShouldBeDisplayed() { $this->dispatch('/admin'); @@ -64,12 +58,6 @@ abstract class AdvancedSearch_ActiveTestCase extends Admin_AbstractControllerTes 'visible' => true ]); } - - - public function tearDown() { - ZendAfi_View_Helper_Admin_MenuGaucheAdminItem::setAcl(null); - parent::tearDown(); - } }