Lines 19-32
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
23 |
|
23 |
|
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
26 |
|
26 |
|
|
|
27 |
use t::lib::Mocks; |
27 |
use t::lib::TestBuilder; |
28 |
use t::lib::TestBuilder; |
28 |
|
29 |
|
29 |
use Koha::Libraries; |
30 |
use Koha::Libraries; |
|
|
31 |
use Koha::Old::Holds; |
30 |
|
32 |
|
31 |
my $schema = Koha::Database->new->schema; |
33 |
my $schema = Koha::Database->new->schema; |
32 |
my $builder = t::lib::TestBuilder->new; |
34 |
my $builder = t::lib::TestBuilder->new; |
Lines 202-204
subtest 'is_pickup_location_valid() tests' => sub {
Link Here
|
202 |
|
204 |
|
203 |
$schema->storage->txn_rollback; |
205 |
$schema->storage->txn_rollback; |
204 |
}; |
206 |
}; |
205 |
- |
207 |
|
|
|
208 |
subtest 'cancel() tests' => sub { |
209 |
|
210 |
plan tests => 3; |
211 |
|
212 |
$schema->storage->txn_begin; |
213 |
|
214 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
215 |
|
216 |
# reduce the tests noise |
217 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
218 |
t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', |
219 |
undef ); |
220 |
|
221 |
# 0 == keep forever |
222 |
$patron->privacy(0)->store; |
223 |
my $hold = $builder->build_object( |
224 |
{ |
225 |
class => 'Koha::Holds', |
226 |
value => { borrowernumber => $patron->id, status => undef } |
227 |
} |
228 |
); |
229 |
$hold->cancel(); |
230 |
is( Koha::Old::Holds->find( $hold->id )->borrowernumber, |
231 |
$patron->borrowernumber, 'Patron link is kept' ); |
232 |
|
233 |
# 1 == "default", meaning it is not protected from removal |
234 |
$patron->privacy(1)->store; |
235 |
$hold = $builder->build_object( |
236 |
{ |
237 |
class => 'Koha::Holds', |
238 |
value => { borrowernumber => $patron->id, status => undef } |
239 |
} |
240 |
); |
241 |
$hold->cancel(); |
242 |
is( Koha::Old::Holds->find( $hold->id )->borrowernumber, |
243 |
$patron->borrowernumber, 'Patron link is kept' ); |
244 |
|
245 |
# 2 == delete immediately |
246 |
$patron->privacy(2)->store; |
247 |
$hold = $builder->build_object( |
248 |
{ |
249 |
class => 'Koha::Holds', |
250 |
value => { borrowernumber => $patron->id, status => undef } |
251 |
} |
252 |
); |
253 |
$hold->cancel(); |
254 |
is( Koha::Old::Holds->find( $hold->id )->borrowernumber, |
255 |
undef, 'Patron link is deleted immediately' ); |
256 |
|
257 |
$schema->storage->txn_rollback; |
258 |
}; |