diff --git a/application/modules/admin/controllers/AccueilController.php b/application/modules/admin/controllers/AccueilController.php index 27792abc7b324e8eb8a7f306a006e71eba2646c6..47c99d2c9bb5c7c29fdfa2eab969c35b9510e734 100644 --- a/application/modules/admin/controllers/AccueilController.php +++ b/application/modules/admin/controllers/AccueilController.php @@ -152,11 +152,6 @@ class Admin_AccueilController extends Zend_Controller_Action { public function loginAction() { - $this->view->getHelper('ComboProfils') - ->setTagId('profil_redirect') - ->setTagName('profil_redirect') - ->addEmptyOption(); - $this->_simpleAction(); } diff --git a/application/modules/admin/views/scripts/modules/auth_form.phtml b/application/modules/admin/views/scripts/modules/auth_form.phtml index 90c22cde8a44e7aef4111ca48ebcff9a92e782f9..409e5a6fcdf99b59af1104c0304c14633149de5d 100644 --- a/application/modules/admin/views/scripts/modules/auth_form.phtml +++ b/application/modules/admin/views/scripts/modules/auth_form.phtml @@ -66,7 +66,6 @@ <td class="gauche"><input type="text" name="lien_compte" size="50" value="<?php print($this->preferences["lien_compte"]); ?>"></td> </tr> - <tr> <td class="droite">Libelle lien nouveau compte </td> <td class="gauche"><input type="text" name="lien_creer_compte" size="50" value="<?php print($this->preferences["lien_creer_compte"]); ?>"></td> @@ -75,19 +74,24 @@ <tr> <td class="droite">Basculer automatiquement sur le profil: </td> <td class="gauche"> - <?php echo $this->ComboProfils('ALL', 'ALL', $this->preferences['profil_redirect']); + <?php + $this->getHelper('ComboProfils') + ->setTagId('profil_redirect') + ->setTagName('profil_redirect') + ->addEmptyOption(); + echo $this->comboProfils('ALL', 'ALL', $this->preferences['profil_redirect']); ?> </td> </tr> - <tr> <td class="droite">Déconnexion : basculer sur le profil: </td> <td class="gauche"> - <?php $this->getHelper('ComboProfils') - ->setTagId('profil_deco_redirect') - ->setTagName('profil_deco_redirect'); - echo $this->ComboProfils('ALL', 'ALL', $this->preferences['profil_deco_redirect']); + <?php $this->getHelper('ComboProfils') + ->setTagId('profil_logout_redirect') + ->setTagName('profil_logout_redirect') + ->addEmptyOption(); + echo $this->comboProfils('ALL', 'ALL', $this->preferences['profil_logout_redirect']); ?> </td> </tr> diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index 8e856c425348cb58bfa54eae58cb86fdce5c3f46..b28b4a2bf0d1180d95c384fa0d55d2eb5127b397 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -18,18 +18,14 @@ * along with AFI-OPAC 2.0; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3: AUTHENTIFICATION ABONNE -// -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class AuthController extends ZendAfi_Controller_Action { - function init() { + public function init() { $this->view->locale = Zend_Registry::get('locale'); } - function indexAction() { + public function indexAction() { $this->_redirect('/opac'); } @@ -43,10 +39,12 @@ class AuthController extends ZendAfi_Controller_Action { return $this->_request->getParam('service'); } + public function notify($message) { $this->_helper->notify($message); } + public function getRedirectDefaultUrl() { return $this->_request->getParam('redirect','/opac'); } @@ -57,7 +55,6 @@ class AuthController extends ZendAfi_Controller_Action { } - public function _authenticate() { $f = new Zend_Filter_StripTags(); $username = $f->filter($this->_request->getPost('username')); @@ -77,7 +74,7 @@ class AuthController extends ZendAfi_Controller_Action { } - function loginAction() { + public function loginAction() { $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); $redirect = $this->_getParam('redirect', '/opac'); $this->view->redirect = $redirect; @@ -92,7 +89,7 @@ class AuthController extends ZendAfi_Controller_Action { } - function ajaxLoginAction(){ + public function ajaxLoginAction(){ $this->view->preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); $strategy = Auth_Strategy_Abstract::strategyForController($this); $strategy->disableRedirect(); @@ -109,7 +106,7 @@ class AuthController extends ZendAfi_Controller_Action { } - function popupLoginAction() { + public function popupLoginAction() { $page_settings = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); $widget_settings = Class_Profil::getCurrentProfil()->getModuleAccueilPreferencesByType('LOGIN'); $this->view->preferences = @@ -118,7 +115,7 @@ class AuthController extends ZendAfi_Controller_Action { :( $page_settings ? $page_settings : []); - //$this->view->preferences = + $this->view->redirect = $this->_getParam('redirect'); $this->renderPopupResult($this->view->_('Authentification'), @@ -126,23 +123,21 @@ class AuthController extends ZendAfi_Controller_Action { } - function boiteLoginAction() { + public function boiteLoginAction() { $this->view->preferences = Class_Profil::getCurrentProfil()->getModuleAccueilPreferencesByType('LOGIN'); $strategy = Auth_Strategy_Abstract::strategyForController($this); $strategy->setDefaultUrl($this->_request->getServer('HTTP_REFERER')); $strategy->processLogin(); - } - function ajaxlostpassAction() { - if($_POST) - { - $user=ZendAfi_Filters_Post::filterStatic($this->_request->getPost('username')); + public function ajaxlostpassAction() { + if ($this->_request->isPost()) { + $user = ZendAfi_Filters_Post::filterStatic($this->_request->getPost('username')); $classe_user = new Class_Users(); - $ret=$classe_user->lostpass($user); - $this->view->message=$this->messages[$ret["error"]]; - $this->view->message_mail=$ret["message_mail"]; + $ret = $classe_user->lostpass($user); + $this->view->message = $this->messages[$ret["error"]]; + $this->view->message_mail = $ret["message_mail"]; } $this->view->username=$user; $viewRenderer = $this->getHelper('ViewRenderer'); @@ -150,17 +145,15 @@ class AuthController extends ZendAfi_Controller_Action { } - function logoutAction() { - $preferences = Class_Profil::getCurrentProfil()->getCfgModulesPreferences('auth','login'); - + public function logoutAction() { ZendAfi_Auth::getInstance()->clearIdentity(); - xdebug_break(); - $this->_redirectToDecoProfil($preferences); + $profil = Class_Profil::getCurrentProfil(); + $this->_redirectToLogoutProfil($profil->getModuleAccueilPreferencesByType('LOGIN')); } - function lostpassAction() { - if($_POST) { + public function lostpassAction() { + if($this->_request->isPost()) { $user = ZendAfi_Filters_Post::filterStatic($this->_request->getPost('username')); $classe_user = new Class_Users(); $ret=$classe_user->lostpass($user); @@ -171,32 +164,29 @@ class AuthController extends ZendAfi_Controller_Action { } - function registerAction() { + public function registerAction() { if (Class_AdminVar::get('INTERDIRE_ENREG_UTIL')) $this->_redirect('/'); - if ($this->_request->isPost()) - { + if ($this->_request->isPost()) { // recup _post - $data=ZendAfi_Filters_Post::filterStatic($this->_request->getPost()); + $data = ZendAfi_Filters_Post::filterStatic($this->_request->getPost()); $class_user = new Class_Users(); $ret=$class_user->registerUser($data); // Affichage des erreurs - if($ret["error"]) - { + if($ret['error']) { $this->view->cle = $this->getCleActivation(); - $this->view->login = $data["login"]; - $this->view->email = $data["mail"]; - $this->view->error = '<div align="center" class="error">'.$ret["error"].'</div>'; + $this->view->login = $data['login']; + $this->view->email = $data['mail']; + $this->view->error = '<div align="center" class="error">' . $ret['error'] . '</div>'; } - $this->view->message_mail=$ret["message_mail"]; + $this->view->message_mail = $ret['message_mail']; } // Opération terminée - if($this->view->message_mail) - { - $this->view->titre=$this->view->_("Votre demande d'inscription"); + if($this->view->message_mail) { + $this->view->titre = $this->view->_("Votre demande d'inscription"); $viewRenderer = $this->getHelper('ViewRenderer'); $viewRenderer->renderScript('auth/message.phtml'); } @@ -206,11 +196,8 @@ class AuthController extends ZendAfi_Controller_Action { $this->view->cle = $this->getCleActivation(); } -//------------------------------------------------------------------------------------------------------ -// Activation d'une nouvelle inscription -//------------------------------------------------------------------------------------------------------ - function activeuserAction() - { + + public function activeuserAction() { if (!$cle = $this->_request->getParam('c')) $this->_redirect('/'); @@ -220,11 +207,8 @@ class AuthController extends ZendAfi_Controller_Action { $this->view->info = urldecode(str_replace('%0D%0A',"<br />", $info)); } -//------------------------------------------------------------------------------------------------------ -// Captcha -//------------------------------------------------------------------------------------------------------ - function generatecaptchaAction() - { + + public function generatecaptchaAction() { $md5_hash = md5(rand(0,999)); $security_code = substr($md5_hash, 15, 5); @@ -234,23 +218,20 @@ class AuthController extends ZendAfi_Controller_Action { $white = ImageColorAllocate($image, 255, 255, 255); // bg image ImageString($image, 3, 30, 3, $security_code, $white); - header("Content-Type: image/jpeg"); + header('Content-Type: image/jpeg'); ImageJpeg($image); $viewRenderer = $this->getHelper('ViewRenderer'); $viewRenderer->setNoRender(); } -//------------------------------------------------------------------------------------------------------ -// genere une cle aleatoire pour l'activation de compte par URL -//------------------------------------------------------------------------------------------------------ - function getCleActivation() { + + public function getCleActivation() { $cle = ''; - for ($i=0; $i< 10; $i++) - { - $nb_ascii = rand(1,26) + 64 ; - $cle.=chr($nb_ascii).rand(0,9); + for ($i=0; $i< 10; $i++) { + $nb_ascii = rand(1, 26) + 64 ; + $cle .= chr($nb_ascii) . rand(0, 9); } - return($cle); + return $cle; } } @@ -258,8 +239,8 @@ class AuthController extends ZendAfi_Controller_Action { abstract class Auth_Strategy_Abstract { - protected $redirect_url=''; - protected $disable_redirect=false; + protected $redirect_url = ''; + protected $disable_redirect = false; static public function strategyForController($controller) { if ($controller->isCasRequest() && static::isLogged()) @@ -276,7 +257,7 @@ abstract class Auth_Strategy_Abstract { static protected function isLogged() { - return Class_Users::getIdentity(); + return Class_Users::getIdentity(); } public function disableRedirect() { @@ -284,8 +265,8 @@ abstract class Auth_Strategy_Abstract { } public function __construct($controller) { - $this->controller=$controller; - $this->default_url=$this->controller->getRedirectDefaultUrl(); + $this->controller = $controller; + $this->default_url = $this->controller->getRedirectDefaultUrl(); } public function getRequest(){ diff --git a/library/Class/Systeme/ModulesAccueil/Login.php b/library/Class/Systeme/ModulesAccueil/Login.php index 1eb5a5f0e47ca6d6601400e83657cf9ecad58e72..e7a2b0d89bef512de46e5c93e2525cf3c8d08abf 100644 --- a/library/Class/Systeme/ModulesAccueil/Login.php +++ b/library/Class/Systeme/ModulesAccueil/Login.php @@ -56,7 +56,7 @@ class Class_Systeme_ModulesAccueil_Login extends Class_Systeme_ModulesAccueil_Nu 'lien_deconnection' => '» Se déconnecter', 'autocomplete_off' => 1 ,// si == 1, rajoute autocomplete="off" au formulaire 'profil_redirect' => '0', - 'profil_deco_redirect' => '0' + 'profil_logout_redirect' => '0' ]; } ?> \ No newline at end of file diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index 93d073a1faedf65be44d1aeddfe7b14c0ed3ac3d..81832e2c78f9016ac35e272aa500beea3243147c 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -105,7 +105,7 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { public function editAction() { if (!$model = $this->_definitions->find($this->_getParam('id'))) { - $this->_rectToIndex(); + $this->_redirectToIndex(); return; } $this->view->titre = $this->_definitions->editActionTitle($model); @@ -142,15 +142,18 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { protected function _redirectToParentProfil() { - $current_profil = Class_Profil::getCurrentProfil(); - $this->_redirect($current_profil->hasParentProfil() ? '/opac/index/index/id_profil/'.$current_profil->getParentProfil()->getId() : '/'); + $profil = Class_Profil::getCurrentProfil(); + $url = $profil->hasParentProfil() ? + '/opac/index/index/id_profil/' . $profil->getParentProfil()->getId() : + '/'; + $this->_redirect($url); } - protected function _redirectToDecoProfil($preferences) { - if ($preferences['profil_deco_redirect']>0) - $this->_redirect('/opac/index/index/id_profil/'.$preferences['profil_deco_redirect']); - else + protected function _redirectToLogoutProfil($preferences) { + $target = (int)$preferences['profil_logout_redirect']; + (0 < $target) ? + $this->_redirect('/opac/index/index/id_profil/' . $target) : $this->_redirectToParentProfil(); } diff --git a/library/ZendAfi/View/Helper/ComboProfils.php b/library/ZendAfi/View/Helper/ComboProfils.php index 41119de64b54dfb2b7d60fe9c8dbabf467107528..468cce5465cb1c3d21f95c0e54e67fce9a037f24 100644 --- a/library/ZendAfi/View/Helper/ComboProfils.php +++ b/library/ZendAfi/View/Helper/ComboProfils.php @@ -18,9 +18,6 @@ * along with AFI-OPAC 2.0; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -////////////////////////////////////////////////////////////////////////////////////////////////////// -// OPAC3 - Combo des menu paramétrés -////////////////////////////////////////////////////////////////////////////////////////////////////// class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { protected @@ -31,15 +28,15 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { $_id_zone, $_id_bib; - function comboProfils($id_zone='ALL', $id_bib='ALL', $id_profil=1, $autoload=false, $empty_option = false) { + public function comboProfils($id_zone='ALL', $id_bib='ALL', $id_profil=1, + $autoload=false, $empty_option=false) { $this->_select_profil_id = $id_profil; - if($empty_option) + if ($empty_option) $this->addEmptyOption(); $this->_id_zone = 'ALL'; $this->_id_bib = 'ALL'; - return $this->renderSelect($autoload, - $this->renderProfilsByBibGroups()); + return $this->renderSelect($autoload, $this->renderProfilsByBibGroups()); } @@ -71,35 +68,36 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { public function renderSelect($autoload ,$content) { - $onchange=''; - if($autoload==true) - $onchange=' onchange="window.location=\''.BASE_URL.'?id_profil=\' + this.value"'; - if ($this->_add_empty_option) - $content = '<option value=""></option>'.$content; + $content = '<option value=""></option>' . $content; + + $extra = ''; + if ($autoload) + $extra = ' onchange="window.location=\''.BASE_URL.'?id_profil=\' + this.value"'; - return '<select id="'.$this->_select_id.'" name="'.$this->_select_name.'"'.$onchange.'>'.$content.'</select>'; + return sprintf('<select id="%s" name="%s"%s>%s</select>', + $this->_select_id, $this->_select_name, $extra, $content); } public function getProfilsByBib() { - $profils = Class_Profil::getLoader()->findAllByZoneAndBib($this->_id_zone, - $this->_id_bib); - $profils_by_bib = array(); + $profils = Class_Profil::findAllByZoneAndBib($this->_id_zone, + $this->_id_bib); + $profils_by_bib = []; foreach ($profils as $profil) { - if ($profil->hasParentProfil()) continue; + if ($profil->hasParentProfil()) + continue; - if ($profil->isInPortail()) { - $libelle = $this->translate()->_('Portail'); - } else { - $libelle = $profil->getBibLibelle(); - } + $libelle = ($profil->isInPortail()) ? + $this->translate()->_('Portail') : + $profil->getBibLibelle(); if (!array_key_exists($libelle, $profils_by_bib)) - $profils_by_bib[$libelle] = array(); + $profils_by_bib[$libelle] = []; - $profils_by_bib[$libelle] []= $profil; + $profils_by_bib[$libelle][]= $profil; } + ksort($profils_by_bib); return $profils_by_bib; @@ -122,7 +120,8 @@ class ZendAfi_View_Helper_ComboProfils extends ZendAfi_View_Helper_BaseHelper { public function renderProfilOption($profil, $libelle) { - $selected = ($this->_select_profil_id == $profil->getId()) ? 'selected="selected"' : ''; + $selected = ($this->_select_profil_id == $profil->getId()) + ? 'selected="selected"' : ''; return '<option value="'.$profil->getId().'" '.$selected.'>'.$libelle.'</option>'; } } \ No newline at end of file diff --git a/tests/application/modules/admin/controllers/AccueilControllerTest.php b/tests/application/modules/admin/controllers/AccueilControllerTest.php index 2b63a84b0e23ad83f11ea0bf9455567fe934059b..67e1c7d31f39630fc68bbee7f8b6e91c385796ff 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerTest.php @@ -477,7 +477,7 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest 'division' => 4, 'id_module' => 32, 'preferences' => ['profil_redirect'=>'1', - 'profil_deco_redirect' => '1', + 'profil_logout_redirect' => '1', 'mot_de_pass_exemple' => 'dd/mm/aaaa']]); $this->dispatch('/admin/accueil/login?config=accueil&type_module=LOGIN&id_module=32', true); } @@ -491,7 +491,7 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest /** @test */ public function selectDecoProfilRedirectShouldContainsProfil1() { - $this->assertXPathContentContains('//select[@id="profil_deco_redirect"][@name="profil_deco_redirect"]/optgroup/option[@value="1"][@selected="selected"]', 'portail: Accueil', $this->_response->getBody()); + $this->assertXPathContentContains('//select[@id="profil_logout_redirect"][@name="profil_logout_redirect"]/optgroup/option[@value="1"][@selected="selected"]', 'portail: Accueil', $this->_response->getBody()); } @@ -562,7 +562,7 @@ class AccueilControllerConfigBoiteLoginTest extends Admin_AbstractControllerTest /** @test **/ public function selectProfilDeconnectionShouldBeEmptyValue() { - $this->assertXPath('//td/select[@id="profil_deco_redirect"]/option'); + $this->assertXPath('//td/select[@id="profil_logout_redirect"]/option'); } } @@ -577,11 +577,10 @@ class AccueilControllerPostConfigBoiteKiosqueProfilLognesTestCase extends Admin_ ->setLibelle('Lognes'); Class_Profil::getCurrentProfil() - ->updateModuleConfigAccueil(25, - array('type_module' => 'KIOSQUE', - 'division' => 4, - 'id_module' => 32, - 'preferences' => array())) + ->updateModuleConfigAccueil(25, ['type_module' => 'KIOSQUE', + 'division' => 4, + 'id_module' => 32, + 'preferences' => []]) ->setIdSite(3); $this->postDispatch('/admin/accueil/kiosque?config=accueil&type_module=KIOSQUE&id_module=32', ['id_panier'=>'5','titre' => 'titre du /kiosque']); diff --git a/tests/application/modules/opac/controllers/AuthControllerTest.php b/tests/application/modules/opac/controllers/AuthControllerTest.php index dafeec35c3384b493b25431bf87b456cb27aece8..4c9d9acadf2dee5c38be4e6e22b7acfa1393c7c9 100644 --- a/tests/application/modules/opac/controllers/AuthControllerTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerTest.php @@ -40,7 +40,7 @@ abstract class PortailWithOneLoginModuleTestCase extends AbstractControllerTestC 'lien_connexion' => 'please, log me', 'lien_mot_de_passe_oublie' => 'me rappelle plus', 'profil_redirect' => 1, - 'profil_deco_redirect' => 5]]], + 'profil_logout_redirect' => 0]]], 'options' => []]; Class_Profil::getCurrentProfil() @@ -154,61 +154,65 @@ class AuthControllerAbonneSIGBLoggedTest extends PortailWithOneLoginModuleTestCa -class AuthControllerAbonneSIGBLoggedLogoutTest extends PortailWithOneLoginModuleTestCase { +class AuthControllerAbonneSIGBLoggedLogoutTest +extends PortailWithOneLoginModuleTestCase { public function setUp() { parent::setUp(); $this->dispatch('/opac/auth/logout'); } + /** @test */ - public function answerShouldRedirectToRoot() { + public function shouldRedirectToRoot() { $this->assertRedirectTo('/'); } } -class AuthControllerWithProfilPageAbonneSIGBLoggedLogoutTest extends PortailWithOneLoginModuleTestCase { + +class AuthControllerWithProfilPageAbonneSIGBLoggedLogoutTest +extends PortailWithOneLoginModuleTestCase { + protected $_profile, $_parent_profile; + public function setUp() { parent::setUp(); - $this->profil_adulte = $this->fixture('Class_Profil', ['id' => 22]) - ->setBrowser('opac') - ->setLibelle('Profil Adulte') - ->setHauteurBanniere(150) - ->setCouleurTexteBandeau('#F2C') - ->setCouleurLienBandeau('#234') - ->setMenuHautOn(true) - ->setCfgMenus([]) - ->setCommentaire('Super bib') - ->setRefTags('bib,Adulte') - ->setParentProfil(Class_Profil::getCurrentProfil()); - $this->profil_adulte->assertSave(); - Class_Profil::setCurrentProfil($this->profil_adulte); - $this->dispatch('/opac/auth/logout'); + $this->_parent_profile = Class_Profil::getCurrentProfil(); + $this->_profile = $this->fixture('Class_Profil', + ['id' => 22, + 'browser' => 'opac', + 'libelle' => 'Profil Adulte', + 'hauteur_banniere' => 150, + 'couleur_texte_bandeau' => '#F2C', + 'couleur_lien_bandeau' => '#234', + 'menu_haut_on' => true, + 'cfg_menus' => [], + 'commentaire' => 'Super bib', + 'ref_tags' => 'bib,Adulte', + 'parent_profil' => $this->_parent_profile]); + Class_Profil::setCurrentProfil($this->_profile); } /** @test **/ - public function linkSeDeconnecterShouldRedirectToParentProfil() { + public function withoutLogoutProfileShouldRedirectToParentProfile() { + $this->dispatch('/opac/auth/logout'); $this->assertRedirectTo('/opac/index/index/id_profil/2'); } -} - + /** @test **/ + public function withLogoutProfile6InParentShouldRedirectToIt() { + $cfg_accueil = $this->_parent_profile->getCfgAccueilAsArray(); + $cfg_accueil['modules'][4]['preferences']['profil_logout_redirect'] = 6; + $this->_parent_profile + ->setCfgAccueil(ZendAfi_Filters_Serialize::serialize($cfg_accueil)); -class AuthControllerWithProfilPageAbonneSIGBLoggedLogoutDeconnectionProfilTest extends PortailWithOneLoginModuleTestCase { - public function setUp() { - parent::setUp(); $this->dispatch('/opac/auth/logout'); + $this->assertRedirectTo('/opac/index/index/id_profil/6'); } +} - - /** @test **/ - public function linkSeDeconnecterShouldRedirectToSelectedProfil5() { - $this->assertRedirectTo('/opac/index/index/id_profil/5'); - } -} abstract class AuthControllerNobodyLoggedTestCase extends PortailWithOneLoginModuleTestCase { @@ -263,7 +267,8 @@ class AuthControllerNobodyLoggedActivateTest extends AuthControllerNobodyLoggedT } -class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest extends AuthControllerNobodyLoggedTestCase { +class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest +extends AuthControllerNobodyLoggedTestCase { public function setUp() { parent::setUp(); @@ -274,40 +279,48 @@ class AuthControllerNobodyLoggedAndRegistrationAllowedBoiteLoginTest extends Aut $this->dispatch('/opac/',true); } + /** @test */ - public function submitButtonSeConnecterShouldBeDisplay(){ - $this->assertXPath('//div[@id="boite_login"]//input[@type="submit"]',$this->_response->getBody()); + public function loginSubmitShouldBePresent(){ + $this->assertXPath('//div[@id="boite_login"]//input[@type="submit"]', + $this->_response->getBody()); } + /** @test */ - public function titreDelaBoiteShouldBeSeConnecter(){ + public function titleShouldBeSeConnecter(){ $this->assertXPathContentContains('//h1','Se connecter'); } + /** @test **/ - public function inputLoginTypePasswordShouldCOntainsOnkeypressFormSubmit() { + public function inputLoginShouldSubmitOnKey13Pressed() { $this->assertXPath('//div[@id="boite_login"]//input[contains(@onkeypress,"if (event.keyCode == 13) {this.form.submit();return false;}")]'); } - public function testLinkSeConnecter() { - $this->assertXPath('//div[@id="boite_login"]//a[contains(@onclick,"submit")]'); + + /** @test */ + public function loginLinkShouldBePresent() { $this->assertXPathContentContains('//div[@id="boite_login"]//a[contains(@onclick, "submit")]', 'please, log me'); } - public function testLinkLostPassword() { - $this->assertXPath('//div[@id="boite_login"]//a[contains(@href, "auth/lostpass")]'); + + /** @test */ + public function lostPassLinkShouldBePresent() { $this->assertXPathContentContains('//div[@id="boite_login"]//tr/td[@colspan="2"]/a[contains(@href, "auth/lostpass")]', 'me rappelle plus'); } - public function testLinkSenregistrer() { - $this->assertXPath('//div[@id="boite_login"]//a[contains(@href, "auth/register")]'); + + /** @test */ + public function registerLinkShouldBePresent() { $this->assertXPathContentContains('//div[@id="boite_login"]//a[contains(@href, "auth/register")]', "S'enregistrer"); } - public function testCanAccessRegisterPage() { + /** @test */ + public function shouldAccessRegisterPage() { $this->bootstrap(); $this->dispatch('auth/register', true); $this->assertAction('register'); @@ -1057,9 +1070,7 @@ class portailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT public function setUp() { parent::setUp(); - Storm_Test_ObjectWrapper::onLoaderOfModel('Class_IntBib') - ->whenCalled('findAllBy') - ->answers([]); + Class_IntBib::beVolatile(); $cfg_accueil = ['modules' => [4 => ['division' => '4', 'id_module' => 4, @@ -1081,14 +1092,14 @@ class portailWithOneLoginModuleTestAndLoggedUserCase extends AbstractControllerT ZendAfi_Auth::getInstance()->logUser( - Class_Users::newInstanceWithId(5, - ['login' => 'Pioup', - 'idabon' => 48, - 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, - 'id_site' => 1, - 'fiche_sigb' => []])); - - + $this->fixture('Class_Users', + ['id' => 5, + 'login' => 'Pioup', + 'idabon' => 48, + 'password' => 'one ok password', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB, + 'id_site' => 1, + 'fiche_sigb' => []])); $this->dispatch('/opac/'); }