diff --git a/VERSIONS_HOTLINE/215900 b/VERSIONS_HOTLINE/215900 new file mode 100644 index 0000000000000000000000000000000000000000..ffc9146ff9127036698c9c83b59e1a343f36696d --- /dev/null +++ b/VERSIONS_HOTLINE/215900 @@ -0,0 +1 @@ + - correctif #215900 : Pré-inscription Nanook : ajout de l'inspecteur gadget \ No newline at end of file diff --git a/application/modules/opac/controllers/AuthController.php b/application/modules/opac/controllers/AuthController.php index c5f15603858e0b9dc8c6173ce6ea47c59fe7c722..80123f390cc1000c8bef0949d3566039b9259bbe 100644 --- a/application/modules/opac/controllers/AuthController.php +++ b/application/modules/opac/controllers/AuthController.php @@ -707,8 +707,8 @@ class AuthController extends ZendAfi_Controller_Action { $registration->send($registration_data); if ($messages = $registration->getLogger()->getMessages()) { - $this->_helper->notify(implode(' ', $messages)); - return $this->_redirectToReferer(); + $this->view->form->setErrorMessages($messages); + return null; } $registration->sendMail($registration_data); diff --git a/library/Class/WebService/SIGB/Nanook/Service.php b/library/Class/WebService/SIGB/Nanook/Service.php index 6a0338552445954393548813162eaffafb5225e0..85e3bb346b911fe1248eb1ba79bff1dfe0d2e7bd 100644 --- a/library/Class/WebService/SIGB/Nanook/Service.php +++ b/library/Class/WebService/SIGB/Nanook/Service.php @@ -270,10 +270,9 @@ class Class_Webservice_SIGB_Nanook_Service $post_params['publicCommentRead'] = static::ILS_COMMENT_READ; - $xml = $this->getWebClient() - ->postData($this->buildQueryURL(['service'=>'UpdatePatronInfo', - 'patronId'=>$emprunteur->getId()]), - $post_params); + $xml = $this->httpPost(['service'=>'UpdatePatronInfo', + 'patronId'=>$emprunteur->getId()], + $post_params); if ($this->_checkXmlPatronError($xml)) return Class_WebService_SIGB_Nanook_Emprunteur::nullInstance(); @@ -532,12 +531,12 @@ class Class_Webservice_SIGB_Nanook_Service $data['site'] = (int) $data['site']; - $url = $this->buildQueryURL(['service' => 'pre-register']); - $xml = $this->getWebClient()->postData($url, $data); + $xml = $this->httpPost(['service' => 'pre-register'], $data); $status = $this->ilsdiCheckXml($xml, 'error', - $this->_('Échec de la préinscription, une erreur est survenue')); + $this->_('Échec de la préinscription, une erreur est survenue: %s', + $this->_findErrorTagInXml($xml, 'message'))); $status['patron_id'] = $this->_getTagData($xml, 'patronId'); diff --git a/library/ZendAfi/View/Helper/RenderForm.php b/library/ZendAfi/View/Helper/RenderForm.php index e42dc00129519818ad694f4a1c33528dd2efdc93..a479072f48179d7f305aa5634f522bd532ecf020 100644 --- a/library/ZendAfi/View/Helper/RenderForm.php +++ b/library/ZendAfi/View/Helper/RenderForm.php @@ -36,12 +36,16 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { $this->_setupTableDecoratorsForForm($form); + $errors = implode(BR, array_map(fn($message) => $this->_tagError($message), $form->getErrorMessages())); + if ($this->_isFormContainsSubmit($form)) - return $form->render(); + return $errors . $form->render(); - return $buttons == static::NO_BUTTONS - ? $form->render() - : $this->_renderFormWithDefaultButtons($form, $buttons); + return + $errors + . ($buttons == static::NO_BUTTONS + ? $form->render() + : $this->_renderFormWithDefaultButtons($form, $buttons)); } diff --git a/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php b/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php index 3bd50929b59c3669d20d858545eb2faf1a13a94d..4b16f64945635605c149eb872d2955c5f5aa9c31 100644 --- a/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php +++ b/tests/application/modules/opac/controllers/AuthControllerPreRegistrationTest.php @@ -41,7 +41,8 @@ abstract class AuthControllerPreRegistrationTestCase extends AbstractControllerT $this->mock_transport = new MockMailTransport(); Zend_Mail::setDefaultTransport($this->mock_transport); - $this->mock_web_client = $this->mock(); + $this->mock_web_client = $this->mock() + ->whenCalled('hasErrors')->answers(false); } @@ -306,14 +307,8 @@ class AuthControllerPreRegistrationKohaPostDispatchWithErrorReturnedTest extends /** @test */ - public function responseShouldRedirectToPreRegistrationError() { - $this->assertRedirectTo('/auth/pre-registration'); - } - - - /** @test */ - public function errorMessageShouldBe() { - $this->assertFlashMessengerContentContains('Échec de la préinscription, les informations saisies sont invalides.'); + public function errorMessageShouldBePresent() { + $this->assertXPathContentContains('//div//p[@class="error"]', 'Échec de la préinscription, les informations saisies sont invalides.'); } } @@ -592,14 +587,8 @@ abstract class AuthControllerPreRegistrationNanookPostErrorTestCase /** @test */ - public function flashMessengerShouldContainsErrorLabel() { - $this->assertFlashMessengerContentContains($this->_errorLabel()); - } - - - /** @test */ - public function responseShouldRedirectToPreRegistrationError() { - $this->assertRedirectTo('/auth/pre-registration'); + public function errorMessageShouldBePresent() { + $this->assertXPath('//div//p[@class="error"]'); } @@ -710,15 +699,9 @@ class AuthControllerPreRegistrationNanookPostDispatchErrorPatronPasswordNotSecur } - /** @test */ - public function responseShouldRedirectToPreRegistrationError() { - $this->assertRedirectTo('/auth/pre-registration'); - } - - /** @test */ public function notifyShouldContainsLeMotDePasseChoisiNestPasSuffisamment() { - $this->assertFlashMessengerContentContains('Le mot de passe choisi est trop simple. Le mot de passe doit comporter au minimum 6 caractères et doit être constitué d\'au moins un chiffre et une lettre.' ); + $this->assertXPathContentContains('//p', 'Le mot de passe choisi est trop simple. Le mot de passe doit comporter au minimum 6 caractères et doit être constitué d\'au moins un chiffre et une lettre.' ); } } @@ -1175,12 +1158,6 @@ abstract class AuthControllerPreRegistrationKohaPostDispatchWithWebServiceErrorT } - /** @test */ - public function responseShouldRedirectToAuthPreRegistration() { - $this->assertRedirectTo('/auth/pre-registration'); - } - - protected function _postData(array $data) : array { return array_merge($data, ['library_id' => '41|GRA']); } @@ -1201,8 +1178,8 @@ class AuthControllerPreRegistrationKohaPostDispatchWithWebServiceThrowErrorTest /** @test */ - public function flashMessengerShouldContainsEchecDeLaPreinscriptionBibliothequeInvalid() { - $this->assertFlashMessengerContentContains('Échec de la préinscription, une erreur inconnue est survenue.'); + public function shouldContainsEchecDeLaPreinscriptionBibliothequeInvalid() { + $this->assertXPathContentContains('//p', 'Échec de la préinscription, une erreur inconnue est survenue.'); } }