diff --git a/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php b/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php index 9202bbb768e00be796f27a83ce2e3500ddc7e6c0..feed42c12195d2613e4a67bada5f6e566dfbe82a 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerChangePasswordTest.php @@ -20,7 +20,7 @@ */ -class AbonneControllerChangePasswordOnKohaTest extends AbstractControllerTestCase { +class AbonneControllerChangePasswordOnKohaWithRestfulTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -100,6 +100,81 @@ class AbonneControllerChangePasswordOnKohaTest extends AbstractControllerTestCas +class AbonneControllerChangePasswordOnKohaWithOutTest extends AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + + $sigb_plage = $this->fixture('Class_IntBib', + ['id' => 3, + 'comm_params' => ['url_serveur' => 'http://plage.com/cgi-bin/koha/ilsdi.pl', + 'restful' => ''], + 'comm_sigb' => Class_IntBib::COM_KOHA + ]); + + $this->fixture('Class_Bib', ['id' => 11, + 'libelle' => 'Bib de la plage', + 'int_bib' => $sigb_plage]); + + $koha_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/koha/ilsdi.pl?service=AuthenticatePatron&username=ml34&password=achanger') + ->answers(true) + + ->beStrict(); + + $sigb_comm = Class_IntBib::find(3)->getSIGBComm(); + $sigb_comm->setWebClient($mock_web_client); + + $borrower = new Class_WebService_SIGB_Emprunteur('ml34', 'ml34'); + + $koha_user->setFicheSigb(['type_comm' => Class_IntBib::COM_KOHA, + 'fiche' => $borrower]); + + ZendAfi_Auth::getInstance()->logUser($koha_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(); + $this->assertEquals('ce1bnm2p', Class_Users::getIdentity()->getPassword()); + } +} + + + + + class AbonneControllerChangePasswordOnNanookTest extends AbstractControllerTestCase { public function setUp() { parent::setUp();