Skip to content
Snippets Groups Projects

[RTFixed] [TestsIP] hotline#194779: fix put patron route erase informations in Koha

Merged Arthur Suzuki requested to merge hotline#194779_fix_koha_info_deleted into master
All threads resolved!
Compare and Show latest version
1 file
+ 67
70
Preferences
Compare changes
@@ -831,12 +831,12 @@ class TemplatesAbonneDispatchMonHistoriqueTest extends TemplatesIntonationAccoun
$pottifar_old->addLoan($pottifar_old_issue);
$this->_mock_emprunts = (new Class_Testing_WebService_SIGB_Koha_Service())
->whenCalled('loansHistory')
->answers($pottifar_old)
->whenCalled('getLoansPerPage')
->answers(3)
->whenCalled('providesPagedLoans')
->answers(false);
->whenCalled('loansHistory')
->answers($pottifar_old)
->whenCalled('getLoansPerPage')
->answers(3)
->whenCalled('providesPagedLoans')
->answers(false);
$this->_emprunteur->setService($this->_mock_emprunts);
@@ -1369,58 +1369,6 @@ class TemplatesAbonneAccountEditTest extends TemplatesIntonationAccountTestCase
'confirm_new_password' => '']);
$this->assertXPathContentContains('//div', 'Une valeur est requise');
}
/** @test */
public function changePasswordPostNewsecretShouldUpdatePasswordUser() {
Class_Crypt::setPhpCommand($this->mock()
->whenCalled('password_hash')
->with('test', PASSWORD_BCRYPT)
->willDo(function($pass, $crypt) { return '$2a$08$gPuCFG7FU2psZ52z5R.ACeW295qSfRJuTd04i/zwjjNI67ZUmVIHe'; })
->whenCalled('password_hash')
->with('newsecret', PASSWORD_BCRYPT)
->willDo(function($pass, $crypt) { return '$2a$08$gPuCFG7FU2psZ52z5R'; })
->whenCalled('password_verify')
->answers(true));
$int_bib = $this->fixture(Class_IntBib::class,
['id' => 1111,
'comm_params' => ['url_serveur' => 'nanookService'],
'comm_sigb' => Class_IntBib::COM_NANOOK]);
$sigb_comm = $int_bib->getSigbComm();
$sigb_comm->setWebClient($this->mock()
->whenCalled('postData')
->with('http://nanookService/service/UpdatePatronInfo/patronId/',
['password' => 'newsecret',
'mail' => '',
'phoneNumber' => ''])
->answers(true)
->beStrict());
$user = Class_Users::getIdentity();
$user
->setIntBib($int_bib)
->setRoleLevel(6)
->save();
$blowfish = (new Class_User_Password($user))->format();
$user
->setPassword($blowfish)
->save();
$this->postDispatch('/opac/abonne/changer-mon-mot-de-passe/id_profil/72',
['current_password' => 'test',
'new_password' => 'newsecret',
'confirm_new_password' => 'newsecret']);
$this->assertEquals('$2a$08$gPuCFG7FU2psZ52z5R', Class_Users::getIdentity()->getPassword());
}
}
@@ -2543,13 +2491,13 @@ abstract class TemplatesAbonnePaginatedLoansSortByTestCase
protected function _getModels() : array {
Class_Users::getIdentity()
->addChildCard($this->fixture(Class_Users::class,
[ 'id' => 123,
'nom' => 'Souricier',
'prenom' => 'Gris',
'login' => '01234',
'date_fin' => '2024-01-01',
'password' => 's3cr3t',
'idAbon' => '091234']));
[ 'id' => 123,
'nom' => 'Souricier',
'prenom' => 'Gris',
'login' => '01234',
'date_fin' => '2024-01-01',
'password' => 's3cr3t',
'idAbon' => '091234']));
$cards = new Class_User_Cards(Class_Users::getIdentity());
$item = $this->fixture(Class_Exemplaire::class,
@@ -2566,10 +2514,10 @@ abstract class TemplatesAbonnePaginatedLoansSortByTestCase
'url_image' => 'https://monimage.org/chr',
'unimarc' => (new Class_NoticeUnimarc_Fluent)
->zoneWithChildren('200', ['a' => 'Chroniques de la lune Noire',
'f' => 'Ledroit, froideval',
'h' => 't. 1'])
'f' => 'Ledroit, froideval',
'h' => 't. 1'])
->render()
])]);
])]);
$chroniques = new Class_WebService_SIGB_Emprunt('15', new Class_WebService_SIGB_Exemplaire(12390));
$chroniques
@@ -2607,8 +2555,8 @@ abstract class TemplatesAbonnePaginatedLoansSortByTestCase
->zoneWithChildren('200', ['a' => 'Elric le nécromancien',
'f' => 'Michael Moorcock',
'h' => 't. 1'])
->render()
])]));
->render()
])]));
$elric->parseExtraAttributes(['Dateretourprevue' => '25/10/2010',
'Section' => 'Espace jeunesse',
@@ -2681,3 +2629,52 @@ class TemplatesAbonnePretsSortByIssueDateDescTest
[4, 'Elric le n', '06/09/2001' ]];
}
}
class TemplatesAbonneChangePasswordAsAdminTest extends AbstractControllerTestCase
{
public function setUp()
{
parent::setUp();
Class_Crypt::setPhpCommand($this->mock()
->whenCalled('password_hash')
->with('mdp', PASSWORD_BCRYPT)
->willDo(fn($pass, $crypt) => '$2a$08$gPuCFG7FU2psZ52z5R.ACeW295qSfRJuTd04i/zwjjNI67ZUmVIHe')
->whenCalled('password_hash')
->with('test', PASSWORD_BCRYPT)
->willDo(fn($pass, $crypt) => '$2a$08$gPuCFG7FU2psZ52z5R.ACeW295qSfRJuTd04i/zwjjNI67ZUmVIHe')
->whenCalled('password_hash')
->with('newsecret', PASSWORD_BCRYPT)
->willDo(fn($pass, $crypt) => '$2a$08$gPuCFG7FU2psZ52z5R')
->whenCalled('password_verify')
->answers(true));
$user = $this->fixture(Class_Users::class,
['id' => 789789,
'login' => 'admin Jojo',
'password' => 'test',
'role_level' => ZendAfi_Acl_AdminControllerRoles::ADMIN_PORTAIL
]);
ZendAfi_Auth::getInstance()->logUser($user);
$this->postDispatch('/opac/abonne/changer-mon-mot-de-passe/id_profil/72',
['current_password' => 'test',
'new_password' => 'newsecret',
'confirm_new_password' => 'newsecret']);
}
/** @test */
public function changePasswordPostNewsecretShouldUpdatePasswordUser()
{
$this->assertEquals('$2a$08$gPuCFG7FU2psZ52z5R', Class_Users::getIdentity()->getPassword());
}
}