Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 13; |
22 |
use Test::More tests => 14; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
25 |
use C4::Members; |
25 |
use C4::Members; |
Lines 190-231
subtest 'is_expired' => sub {
Link Here
|
190 |
$patron->delete; |
190 |
$patron->delete; |
191 |
}; |
191 |
}; |
192 |
|
192 |
|
193 |
subtest 'is_going_to_expired' => sub { |
193 |
subtest 'is_going_to_expire' => sub { |
194 |
plan tests => 9; |
194 |
plan tests => 9; |
195 |
my $patron = $builder->build({ source => 'Borrower' }); |
195 |
my $patron = $builder->build({ source => 'Borrower' }); |
196 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
196 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
197 |
$patron->dateexpiry( undef )->store->discard_changes; |
197 |
$patron->dateexpiry( undef )->store->discard_changes; |
198 |
is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is not set'); |
198 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is not set'); |
199 |
$patron->dateexpiry( '0000-00-00' )->store->discard_changes; |
199 |
$patron->dateexpiry( '0000-00-00' )->store->discard_changes; |
200 |
is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is not 0000-00-00'); |
200 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is not 0000-00-00'); |
201 |
|
201 |
|
202 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); |
202 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); |
203 |
$patron->dateexpiry( dt_from_string )->store->discard_changes; |
203 |
$patron->dateexpiry( dt_from_string )->store->discard_changes; |
204 |
is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is today'); |
204 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is today'); |
205 |
|
205 |
|
206 |
$patron->dateexpiry( dt_from_string )->store->discard_changes; |
206 |
$patron->dateexpiry( dt_from_string )->store->discard_changes; |
207 |
is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is today and pref is 0'); |
207 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is today and pref is 0'); |
208 |
|
208 |
|
209 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
209 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
210 |
$patron->dateexpiry( dt_from_string->add( days => 11 ) )->store->discard_changes; |
210 |
$patron->dateexpiry( dt_from_string->add( days => 11 ) )->store->discard_changes; |
211 |
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'); |
211 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 11 days ahead and pref is 10'); |
212 |
|
212 |
|
213 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); |
213 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); |
214 |
$patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; |
214 |
$patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; |
215 |
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'); |
215 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 0'); |
216 |
|
216 |
|
217 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
217 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
218 |
$patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; |
218 |
$patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; |
219 |
is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 10'); |
219 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 10 days ahead and pref is 10'); |
220 |
$patron->delete; |
220 |
$patron->delete; |
221 |
|
221 |
|
222 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
222 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
223 |
$patron->dateexpiry( dt_from_string->add( days => 20 ) )->store->discard_changes; |
223 |
$patron->dateexpiry( dt_from_string->add( days => 20 ) )->store->discard_changes; |
224 |
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'); |
224 |
is( $patron->is_going_to_expire, 0, 'Patron should not be considered going to expire if dateexpiry is 20 days ahead and pref is 10'); |
225 |
|
225 |
|
226 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 20); |
226 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 20); |
227 |
$patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; |
227 |
$patron->dateexpiry( dt_from_string->add( days => 10 ) )->store->discard_changes; |
228 |
is( $patron->is_going_to_expired, 1, 'Patron should be considered going to expire if dateexpiry is 10 days ahead and pref is 20'); |
228 |
is( $patron->is_going_to_expire, 1, 'Patron should be considered going to expire if dateexpiry is 10 days ahead and pref is 20'); |
229 |
|
229 |
|
230 |
$patron->delete; |
230 |
$patron->delete; |
231 |
}; |
231 |
}; |
232 |
- |
|
|