|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 42; |
22 |
use Test::More tests => 43; |
| 23 |
use Test::NoWarnings; |
23 |
use Test::NoWarnings; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
use Test::Warn; |
25 |
use Test::Warn; |
|
Lines 3309-3311
subtest 'is_anonymous' => sub {
Link Here
|
| 3309 |
$schema->storage->txn_rollback; |
3309 |
$schema->storage->txn_rollback; |
| 3310 |
|
3310 |
|
| 3311 |
}; |
3311 |
}; |
| 3312 |
- |
3312 |
|
|
|
3313 |
subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { |
| 3314 |
|
| 3315 |
plan tests => 13; |
| 3316 |
|
| 3317 |
$schema->storage->txn_begin; |
| 3318 |
|
| 3319 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3320 |
my $hold1 = $builder->build_object( |
| 3321 |
{ |
| 3322 |
class => 'Koha::Holds', |
| 3323 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3324 |
} |
| 3325 |
); |
| 3326 |
my $hold2 = $builder->build_object( |
| 3327 |
{ |
| 3328 |
class => 'Koha::Holds', |
| 3329 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3330 |
} |
| 3331 |
); |
| 3332 |
my $hold3 = $builder->build_object( |
| 3333 |
{ |
| 3334 |
class => 'Koha::Holds', |
| 3335 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3336 |
} |
| 3337 |
); |
| 3338 |
|
| 3339 |
my $hold4 = $builder->build_object( |
| 3340 |
{ |
| 3341 |
class => 'Koha::Holds', |
| 3342 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3343 |
} |
| 3344 |
); |
| 3345 |
my $hold5 = $builder->build_object( |
| 3346 |
{ |
| 3347 |
class => 'Koha::Holds', |
| 3348 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3349 |
} |
| 3350 |
); |
| 3351 |
|
| 3352 |
my $hold6 = $builder->build_object( |
| 3353 |
{ |
| 3354 |
class => 'Koha::Holds', |
| 3355 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3356 |
} |
| 3357 |
); |
| 3358 |
|
| 3359 |
my $patron_hold_groups = $patron->hold_groups; |
| 3360 |
is( $patron_hold_groups->count, 0, 'Patron does not have any hold groups' ); |
| 3361 |
|
| 3362 |
# Create 1st hold group |
| 3363 |
$patron->create_hold_group( [ $hold1->reserve_id, $hold2->reserve_id, $hold3->reserve_id ] ); |
| 3364 |
is( $patron_hold_groups->count, 1, 'Patron has one hold group' ); |
| 3365 |
|
| 3366 |
my $hold_group = $patron->hold_groups->as_list->[0]; |
| 3367 |
is( $hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); |
| 3368 |
is( $hold_group->hold_group_id, $hold1->get_from_storage->hold_group_id, 'hold1 added to hold_group' ); |
| 3369 |
is( $hold_group->hold_group_id, $hold2->get_from_storage->hold_group_id, 'hold2 added to hold_group' ); |
| 3370 |
is( $hold_group->hold_group_id, $hold3->get_from_storage->hold_group_id, 'hold3 added to hold_group' ); |
| 3371 |
|
| 3372 |
# Create 2nd hold group |
| 3373 |
$patron->create_hold_group( [ $hold4->reserve_id, $hold5->reserve_id ] ); |
| 3374 |
is( $patron_hold_groups->count, 2, 'Patron has two hold groups' ); |
| 3375 |
|
| 3376 |
my $second_hold_group = $patron->hold_groups->as_list->[1]; |
| 3377 |
is( $second_hold_group->visual_hold_group_id, 2, 'Visual hold group id is 2' ); |
| 3378 |
is( |
| 3379 |
$second_hold_group->hold_group_id, $hold4->get_from_storage->hold_group_id, |
| 3380 |
'hold4 added to second hold_group' |
| 3381 |
); |
| 3382 |
is( |
| 3383 |
$second_hold_group->hold_group_id, $hold5->get_from_storage->hold_group_id, |
| 3384 |
'hold5 added to second hold_group' |
| 3385 |
); |
| 3386 |
|
| 3387 |
$hold3->get_from_storage->fill(); |
| 3388 |
is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one hold group again' ); |
| 3389 |
|
| 3390 |
$hold4->get_from_storage->cancel(); |
| 3391 |
is( $patron->get_from_storage->hold_groups->count, 0, 'Patron does not have any hold groups again' ); |
| 3392 |
|
| 3393 |
# Create 3rd hold group |
| 3394 |
$patron->create_hold_group( [ $hold5->reserve_id, $hold6->reserve_id ] ); |
| 3395 |
my $third_hold_group = $patron->hold_groups->as_list->[0]; |
| 3396 |
is( $third_hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); |
| 3397 |
|
| 3398 |
$schema->storage->txn_rollback; |
| 3399 |
}; |