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

(-)a/Koha/Patron.pm (+16 lines)
Lines 266-271 sub is_debarred { Link Here
266
    return;
266
    return;
267
}
267
}
268
268
269
=head2 is_expired
270
271
my $is_expired = $patron->is_expired;
272
273
Returns 1 if the patron is expired or 0;
274
275
=cut
276
277
sub is_expired {
278
    my ($self) = @_;
279
    return 0 unless $self->dateexpiry;
280
    return 0 if $self->dateexpiry eq '0000-00-00';
281
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string;
282
    return 0;
283
}
284
269
=head2 update_password
285
=head2 update_password
270
286
271
my $updated = $patron->update_password( $userid, $password );
287
my $updated = $patron->update_password( $userid, $password );
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +19 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 11;
22
use Test::More tests => 12;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use C4::Members;
25
use C4::Members;
Lines 165-170 subtest 'update_password' => sub { Link Here
165
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
165
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
166
};
166
};
167
167
168
subtest 'is_expired' => sub {
169
    plan tests => 5;
170
    my $patron = $builder->build({ source => 'Borrower' });
171
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
172
    $patron->dateexpiry( undef )->store;
173
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
174
    $patron->dateexpiry( '0000-00-00' )->store;
175
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00');
176
    $patron->dateexpiry( dt_from_string )->store;
177
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
178
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store;
179
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
180
    $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store;
181
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
182
183
    $patron->delete;
184
};
185
168
subtest 'renew_account' => sub {
186
subtest 'renew_account' => sub {
169
    plan tests => 10;
187
    plan tests => 10;
170
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
188
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
171
- 

Return to bug 17579