From 79b6a1dbb1287c84a7c6db2a399629861c5f6510 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@afi-sa.fr> Date: Fri, 4 Mar 2016 11:36:27 +0100 Subject: [PATCH] hotline #36324 : fix error messages display on smartphone login page --- .../modules/telephone/controllers/AuthController.php | 2 +- .../views/scripts/auth/login-reservation.phtml | 12 +++++++++--- .../telephone/controllers/AuthControllerTest.php | 11 +++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/application/modules/telephone/controllers/AuthController.php b/application/modules/telephone/controllers/AuthController.php index 3f6bed50985..763316755d0 100644 --- a/application/modules/telephone/controllers/AuthController.php +++ b/application/modules/telephone/controllers/AuthController.php @@ -79,7 +79,7 @@ class Telephone_AuthController extends AuthController { $this->_redirect($this->view->url(), array('prependBase' => false)); } - $this->view->error = $this->_flashMessenger->getMessages(); + $this->view->error = $this->_flashMessenger->getNotifications(); $this->view->form = $form; } diff --git a/application/modules/telephone/views/scripts/auth/login-reservation.phtml b/application/modules/telephone/views/scripts/auth/login-reservation.phtml index db6c45feb3b..11d718b4444 100644 --- a/application/modules/telephone/views/scripts/auth/login-reservation.phtml +++ b/application/modules/telephone/views/scripts/auth/login-reservation.phtml @@ -1,5 +1,11 @@ <?php echo $this->toolbar($this->_("Identification"));?> <div data-role="content"> - <?php echo $this->form;?> - <?php if (0 < count($this->error)) echo '<strong style="color:red">' . $this->error[0] . '</strong>';?> -</div> \ No newline at end of file + <?php + + echo $this->form; + + foreach($this->error as $error) { + echo '<strong style="color:red">' . $error->getMessage() . '</strong>'; + } + ?> +</div> diff --git a/tests/application/modules/telephone/controllers/AuthControllerTest.php b/tests/application/modules/telephone/controllers/AuthControllerTest.php index 3955605151b..79742371b3b 100644 --- a/tests/application/modules/telephone/controllers/AuthControllerTest.php +++ b/tests/application/modules/telephone/controllers/AuthControllerTest.php @@ -109,6 +109,11 @@ class AuthControllerTelephoneLoginReservationTest extends AuthControllerTelephon ->whenCalled('hasIdentity') ->answers(false); + + $messenger = new ZendAfi_Controller_Action_Helper_FlashMessenger(); + $messenger->addNotification('An error occured'); + ZendAfi_Controller_Action_Helper_FlashMessenger::reset(); + $this->dispatch('auth/login-reservation/id/45324', true); } @@ -136,6 +141,11 @@ class AuthControllerTelephoneLoginReservationTest extends AuthControllerTelephon $this->assertXPath('//form//input[@placeholder="password"]', $this->_response->getBody()); } + + /** @test */ + public function pageShouldContainsAnErrorOccured() { + $this->assertXPathContentContains('//div', 'An error occured', $this->_response->getBody()); + } } @@ -162,6 +172,7 @@ class AuthControllerTelephoneLoginReservationInvalidPostTest extends AuthControl public function flashMessengerShouldContainsErrorMessage() { $this->assertFlashMessengerContains('Entrez votre identifiant S.V.P.'); } + } -- GitLab