From ebcf64fc854331b85ad993c5b9aea52de456ffed Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 21 Mar 2017 21:18:17 -0300 Subject: [PATCH] Bug 18314: Add tests Signed-off-by: Jonathan Field --- t/db_dependent/Koha/Patrons.t | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 74f0e7f..a68ab6c 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 21; +use Test::More tests => 22; use Test::Warn; use DateTime; @@ -881,6 +881,26 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; }; +subtest 'account_locked' => sub { + plan tests => 8; + my $patron = $builder->build({ source => 'Borrower', value => { login_attempts => 0 } }); + $patron = Koha::Patrons->find( $patron->{borrowernumber} ); + for my $value ( undef, '', 0 ) { + t::lib::Mocks::mock_preference('FailedloginAttempts', $value); + is( $patron->account_locked, 0, 'Feature is disabled, patron account should not be considered locked' ); + $patron->login_attempts(1)->store; + is( $patron->account_locked, 0, 'Feature is disabled, patron account should not be considered locked' ); + } + + t::lib::Mocks::mock_preference('FailedloginAttempts', 3); + $patron->login_attempts(2)->store; + is( $patron->account_locked, 0, 'Patron has 2 failed attempts, account should not be considered locked yet' ); + $patron->login_attempts(3)->store; + is( $patron->account_locked, 1, 'Patron has 3 failed attempts, account should be considered locked yet' ); + + $patron->delete; +}; + $retrieved_patron_1->delete; is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); -- 2.9.3