From 3e204ecf63a1d730d87bf98c6530b80f9e4b4f93 Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 25 Apr 2018 13:56:08 +0200 Subject: [PATCH] dev #59224 add tests for nanook --- .../Class/WebService/SIGB/AbstractService.php | 3 + .../AbonneControllerChangePasswordTest.php | 69 ++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/library/Class/WebService/SIGB/AbstractService.php b/library/Class/WebService/SIGB/AbstractService.php index 8a18303dc05..d3c33f87fbd 100644 --- a/library/Class/WebService/SIGB/AbstractService.php +++ b/library/Class/WebService/SIGB/AbstractService.php @@ -199,6 +199,9 @@ abstract class Class_WebService_SIGB_AbstractService { } + public function changePasswordOfBy($user, $new_password) {} + + abstract public function getServerRoot(); abstract public function getEmprunteur($user); diff --git a/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php b/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php index 236a6a322e8..8f4c312f0bb 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php @@ -20,7 +20,7 @@ */ -class AbonneControllerChangePasswordOnKohaTestCase extends AbstractControllerTestCase { +class AbonneControllerChangePasswordOnKohaTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -84,6 +84,73 @@ class AbonneControllerChangePasswordOnKohaTestCase extends AbstractControllerTes } + /** @test */ + public function userPasswordShouldHaveBeenUpdatedToCe1bnm2p() { + Class_Users::clearCache(); + $this->assertEquals('ce1bnm2p', Class_Users::getIdentity()->getPassword()); + } +} + + + + +class AbonneControllerChangePasswordOnNanookTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $sigb_plage = $this->fixture('Class_IntBib', + ['id' => 3, + 'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/nanook/ilsdi.pl'], + 'comm_sigb' => Class_IntBib::COM_NANOOK + ]); + + $this->fixture('Class_Bib', ['id' => 11, + 'libelle' => 'Bib de la plage', + 'int_bib' => $sigb_plage]); + + $nanook_user = $this->fixture('Class_Users', + ['id' => 5, + 'login' => 'ml34', + 'password' => 'achanger', + 'id_site' => 11, + 'int_bib' => $sigb_plage, + 'idabon' => '123456', + 'role_level' => ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB]); + + $mock_web_client = $this->mock() + ->whenCalled('open_url') + ->with('http://plage.com/cgi-bin/nanook/ilsdi.pl/service/AuthenticatePatron/username/ml34/password/achanger') + ->answers(true) + + ->beStrict(); + + $sigb_comm = Class_IntBib::find(3)->getSIGBComm(); + $sigb_comm->setWebClient($mock_web_client); + ZendAfi_Auth::getInstance()->logUser($nanook_user); + + $logger = $this->mock() + ->whenCalled('log')->answers(true) + + ->whenCalled('logError') + ->willDo( + function($url, $message) { + var_dump($url . ' :: ' . $message); + exit; + }); + + Class_WebService_SIGB_AbstractService::setLogger($logger); + $this->postDispatch('/abonne/edit', ['password' => 'ce1bnm2p', + 'confirm_password' => 'ce1bnm2p']); + } + + + public function tearDown() { + Class_WebService_SIGB_AbstractService::setLogger(null); + Class_IntBib::find(3)->getSIGBComm()->setWebClient(null); + parent::tearDown(); + } + + /** @test */ public function userPasswordShouldHaveBeenUpdatedToCe1bnm2p() { Class_Users::clearCache(); -- GitLab