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

(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 297-303 sub is_going_to_expired { Link Here
297
297
298
    return 0 unless $self->dateexpiry;
298
    return 0 unless $self->dateexpiry;
299
    return 0 if $self->dateexpiry eq '0000-00-00';
299
    return 0 if $self->dateexpiry eq '0000-00-00';
300
    return 1 if dt_from_string( $self->dateexpiry )->add( days => $delay ) < dt_from_string;
300
    return 1 if dt_from_string( $self->dateexpiry )->add( days => -$delay ) < dt_from_string;
301
    return 0;
301
    return 0;
302
}
302
}
303
303
(-)a/t/db_dependent/Koha/Patrons.t (-10 / +8 lines)
Lines 196-228 subtest 'is_going_to_expired' => sub { Link Here
196
    $patron->dateexpiry( '0000-00-00' )->store;
196
    $patron->dateexpiry( '0000-00-00' )->store;
197
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is not 0000-00-00');
197
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is not 0000-00-00');
198
    $patron->dateexpiry( dt_from_string )->store;
198
    $patron->dateexpiry( dt_from_string )->store;
199
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is today');
199
    is( $patron->is_going_to_expired, 1, 'Patron should be considered going to expire if dateexpiry is today');
200
200
201
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0);
201
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0);
202
    my $dt_from_string = dt_from_string;
202
    $patron->dateexpiry( dt_from_string )->store;
203
    $patron->dateexpiry( $dt_from_string )->store;
203
    is( $patron->is_going_to_expired, 1, 'Patron should be considered going to expire if dateexpiry is today and pref is 0');
204
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is today and pref is 0');
205
204
206
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10);
205
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10);
207
    $patron->dateexpiry( dt_from_string->add( days => 11 ) )->store;
206
    $patron->dateexpiry( dt_from_string->add( days => 11 ) )->store;
208
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 11 days before and pref is 10');
207
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 11 days ahead and pref is 10');
209
208
210
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0);
209
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0);
211
    $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store;
210
    $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store;
212
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days before and pref is 0');
211
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 0');
213
212
214
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10);
213
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10);
215
    $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store;
214
    $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store;
216
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days before and pref is 10');
215
    is( $patron->is_going_to_expired, 1, 'Patron should be considered going to expire if dateexpiry is 10 days ahead and pref is 10');
217
    $patron->delete;
216
    $patron->delete;
218
217
219
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10);
218
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10);
220
    $patron->dateexpiry( dt_from_string->add( days => 20 ) )->store;
219
    $patron->dateexpiry( dt_from_string->add( days => 20 ) )->store;
221
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 20 days before and pref is 10');
220
    is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 20 days ahead and pref is 10');
222
221
223
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 20);
222
    t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 20);
224
    $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store;
223
    $patron->dateexpiry( dt_from_string->add( days => 10 ) )->store;
225
    is( $patron->is_going_to_expired, 1, 'Patron should be considered going to expire if dateexpiry is 10 days before and pref is 20');
224
    is( $patron->is_going_to_expired, 1, 'Patron should be considered going to expire if dateexpiry is 10 days ahead and pref is 20');
226
225
227
    $patron->delete;
226
    $patron->delete;
228
};
227
};
229
- 

Return to bug 17583