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