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

(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 278-284 sub is_expired { Link Here
278
    my ($self) = @_;
278
    my ($self) = @_;
279
    return 0 unless $self->dateexpiry;
279
    return 0 unless $self->dateexpiry;
280
    return 0 if $self->dateexpiry eq '0000-00-00';
280
    return 0 if $self->dateexpiry eq '0000-00-00';
281
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string;
281
    return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' );
282
    return 0;
282
    return 0;
283
}
283
}
284
284
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +5 lines)
Lines 169-183 subtest 'is_expired' => sub { Link Here
169
    plan tests => 5;
169
    plan tests => 5;
170
    my $patron = $builder->build({ source => 'Borrower' });
170
    my $patron = $builder->build({ source => 'Borrower' });
171
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
171
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
172
    $patron->dateexpiry( undef )->store;
172
    $patron->dateexpiry( undef )->store->discard_changes;
173
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
173
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
174
    $patron->dateexpiry( '0000-00-00' )->store;
174
    $patron->dateexpiry( '0000-00-00' )->store->discard_changes;
175
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00');
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;
176
    $patron->dateexpiry( dt_from_string )->store->discard_changes;
177
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
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;
178
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes;
179
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
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;
180
    $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store->discard_changes;
181
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
181
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
182
182
183
    $patron->delete;
183
    $patron->delete;
184
- 

Return to bug 17579