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

(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 291-297 sub is_expired { Link Here
291
    my ($self) = @_;
291
    my ($self) = @_;
292
    return 0 unless $self->dateexpiry;
292
    return 0 unless $self->dateexpiry;
293
    return 0 if $self->dateexpiry eq '0000-00-00';
293
    return 0 if $self->dateexpiry eq '0000-00-00';
294
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string;
294
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' );
295
    return 0;
295
    return 0;
296
}
296
}
297
297
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +5 lines)
Lines 176-190 subtest 'is_expired' => sub { Link Here
176
    plan tests => 5;
176
    plan tests => 5;
177
    my $patron = $builder->build({ source => 'Borrower' });
177
    my $patron = $builder->build({ source => 'Borrower' });
178
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
178
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
179
    $patron->dateexpiry( undef )->store;
179
    $patron->dateexpiry( undef )->store->discard_changes;
180
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
180
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
181
    $patron->dateexpiry( '0000-00-00' )->store;
181
    $patron->dateexpiry( '0000-00-00' )->store->discard_changes;
182
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00');
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;
183
    $patron->dateexpiry( dt_from_string )->store->discard_changes;
184
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
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;
185
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes;
186
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
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;
187
    $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store->discard_changes;
188
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
188
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
189
189
190
    $patron->delete;
190
    $patron->delete;
191
- 

Return to bug 17579