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