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 173-187 subtest 'is_expired' => sub { Link Here
173
    plan tests => 5;
173
    plan tests => 5;
174
    my $patron = $builder->build({ source => 'Borrower' });
174
    my $patron = $builder->build({ source => 'Borrower' });
175
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
175
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
176
    $patron->dateexpiry( undef )->store;
176
    $patron->dateexpiry( undef )->store->discard_changes;
177
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
177
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not set');
178
    $patron->dateexpiry( '0000-00-00' )->store;
178
    $patron->dateexpiry( '0000-00-00' )->store->discard_changes;
179
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00');
179
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is not 0000-00-00');
180
    $patron->dateexpiry( dt_from_string )->store;
180
    $patron->dateexpiry( dt_from_string )->store->discard_changes;
181
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
181
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is today');
182
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store;
182
    $patron->dateexpiry( dt_from_string->add( days => 1 ) )->store->discard_changes;
183
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
183
    is( $patron->is_expired, 0, 'Patron should not be considered expired if dateexpiry is tomorrow');
184
    $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store;
184
    $patron->dateexpiry( dt_from_string->add( days => -1 ) )->store->discard_changes;
185
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
185
    is( $patron->is_expired, 1, 'Patron should be considered expired if dateexpiry is yesterday');
186
186
187
    $patron->delete;
187
    $patron->delete;
188
- 

Return to bug 17579