View | Details | Raw Unified | Return to bug 17579
Collapse All | Expand All

(-)a/Koha/Patron.pm (+16 lines)
Lines 279-284 sub is_debarred { Link Here
279
    return;
279
    return;
280
}
280
}
281
281
282
=head2 is_expired
283
284
my $is_expired = $patron->is_expired;
285
286
Returns 1 if the patron is expired or 0;
287
288
=cut
289
290
sub is_expired {
291
    my ($self) = @_;
292
    return 0 unless $self->dateexpiry;
293
    return 0 if $self->dateexpiry eq '0000-00-00';
294
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string;
295
    return 0;
296
}
297
282
=head2 update_password
298
=head2 update_password
283
299
284
my $updated = $patron->update_password( $userid, $password );
300
my $updated = $patron->update_password( $userid, $password );
(-)a/t/db_dependent/Koha/Patrons.t (-1 / +18 lines)
Lines 172-177 subtest 'update_password' => sub { Link Here
172
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
172
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
173
};
173
};
174
174
175
subtest 'is_expired' => sub {
176
    plan tests => 5;
177
    my $patron = $builder->build({ source => 'Borrower' });
178
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
179
    $patron->dateexpiry( undef )->store;
180
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
181
    $patron->dateexpiry( '0000-00-00' )->store;
182
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00');
183
    $patron->dateexpiry( dt_from_string )->store;
184
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
185
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store;
186
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
187
    $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store;
188
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
189
190
    $patron->delete;
191
};
192
175
subtest 'renew_account' => sub {
193
subtest 'renew_account' => sub {
176
    plan tests => 10;
194
    plan tests => 10;
177
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
195
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
178
- 

Return to bug 17579