$cond->{dateexpiry} = { '<=' => $str };
$cond->{anonymized} = 0; # not yet done
if( $params->{locked} ) {
- my $fails = C4::Context->preference('FailedLoginAttempts');
+ my $fails = C4::Context->preference('FailedLoginAttempts') || 0;
$cond->{login_attempts} = [ -and => { '!=' => undef }, { -not_in => [0, 1..$fails-1 ] } ]; # -not_in does not like undef
}
return $class->search( $cond );
};
subtest 'search_anonymize_candidates' => sub {
- plan tests => 5;
+ plan tests => 7;
my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
my $patron2 = $builder->build_object({ class => 'Koha::Patrons' });
$patron1->anonymized(0);
$patron1->login_attempts(3)->store;
is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
$cnt+1, 'Locked flag' );
+
+ t::lib::Mocks::mock_preference( 'FailedLoginAttempts', q{} );
+ # Patron 1 still on 3 == locked
+ is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
+ $cnt+1, 'Still expect same number for FailedLoginAttempts empty' );
+ $patron1->login_attempts(0)->store;
+ # Patron 1 unlocked
+ is( Koha::Patrons->search_anonymize_candidates({locked => 1})->count,
+ $cnt, 'Patron 1 unlocked' );
};
subtest 'search_anonymized' => sub {