|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 14; |
22 |
use Test::More tests => 15; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
use DateTime; |
24 |
use DateTime; |
| 25 |
|
25 |
|
|
Lines 187-192
subtest 'is_expired' => sub {
Link Here
|
| 187 |
$patron->delete; |
187 |
$patron->delete; |
| 188 |
}; |
188 |
}; |
| 189 |
|
189 |
|
|
|
190 |
subtest 'is_going_to_expired' => sub { |
| 191 |
plan tests => 8; |
| 192 |
my $patron = $builder->build({ source => 'Borrower' }); |
| 193 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 194 |
$patron->dateexpiry( undef )->store; |
| 195 |
is( $patron->is_going_to_expired, 0, 'Patron should not be considered going to expire if dateexpiry is not set'); |
| 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'); |
| 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'); |
| 200 |
|
| 201 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); |
| 202 |
my $dt_from_string = dt_from_string; |
| 203 |
$patron->dateexpiry( $dt_from_string )->store; |
| 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 |
|
| 206 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
| 207 |
$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'); |
| 209 |
|
| 210 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 0); |
| 211 |
$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'); |
| 213 |
|
| 214 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
| 215 |
$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'); |
| 217 |
$patron->delete; |
| 218 |
|
| 219 |
t::lib::Mocks::mock_preference('NotifyBorrowerDeparture', 10); |
| 220 |
$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'); |
| 222 |
|
| 223 |
$patron->delete; |
| 224 |
}; |
| 225 |
|
| 226 |
|
| 190 |
subtest 'renew_account' => sub { |
227 |
subtest 'renew_account' => sub { |
| 191 |
plan tests => 10; |
228 |
plan tests => 10; |
| 192 |
my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); |
229 |
my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); |
| 193 |
- |
|
|