|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 44; |
22 |
use Test::More tests => 45; |
| 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 3364-3366
subtest 'reset_2fa() tests' => sub {
Link Here
|
| 3364 |
|
3364 |
|
| 3365 |
$schema->storage->txn_rollback; |
3365 |
$schema->storage->txn_rollback; |
| 3366 |
}; |
3366 |
}; |
| 3367 |
- |
3367 |
|
|
|
3368 |
subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { |
| 3369 |
|
| 3370 |
plan tests => 13; |
| 3371 |
|
| 3372 |
$schema->storage->txn_begin; |
| 3373 |
|
| 3374 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3375 |
my $hold1 = $builder->build_object( |
| 3376 |
{ |
| 3377 |
class => 'Koha::Holds', |
| 3378 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3379 |
} |
| 3380 |
); |
| 3381 |
my $hold2 = $builder->build_object( |
| 3382 |
{ |
| 3383 |
class => 'Koha::Holds', |
| 3384 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3385 |
} |
| 3386 |
); |
| 3387 |
my $hold3 = $builder->build_object( |
| 3388 |
{ |
| 3389 |
class => 'Koha::Holds', |
| 3390 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3391 |
} |
| 3392 |
); |
| 3393 |
|
| 3394 |
my $hold4 = $builder->build_object( |
| 3395 |
{ |
| 3396 |
class => 'Koha::Holds', |
| 3397 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3398 |
} |
| 3399 |
); |
| 3400 |
my $hold5 = $builder->build_object( |
| 3401 |
{ |
| 3402 |
class => 'Koha::Holds', |
| 3403 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3404 |
} |
| 3405 |
); |
| 3406 |
|
| 3407 |
my $hold6 = $builder->build_object( |
| 3408 |
{ |
| 3409 |
class => 'Koha::Holds', |
| 3410 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
| 3411 |
} |
| 3412 |
); |
| 3413 |
|
| 3414 |
my $patron_hold_groups = $patron->hold_groups; |
| 3415 |
is( $patron_hold_groups->count, 0, 'Patron does not have any hold groups' ); |
| 3416 |
|
| 3417 |
# Create 1st hold group |
| 3418 |
$patron->create_hold_group( [ $hold1->reserve_id, $hold2->reserve_id, $hold3->reserve_id ] ); |
| 3419 |
is( $patron_hold_groups->count, 1, 'Patron has one hold group' ); |
| 3420 |
|
| 3421 |
my $hold_group = $patron->hold_groups->as_list->[0]; |
| 3422 |
is( $hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); |
| 3423 |
is( $hold_group->hold_group_id, $hold1->get_from_storage->hold_group_id, 'hold1 added to hold_group' ); |
| 3424 |
is( $hold_group->hold_group_id, $hold2->get_from_storage->hold_group_id, 'hold2 added to hold_group' ); |
| 3425 |
is( $hold_group->hold_group_id, $hold3->get_from_storage->hold_group_id, 'hold3 added to hold_group' ); |
| 3426 |
|
| 3427 |
# Create 2nd hold group |
| 3428 |
$patron->create_hold_group( [ $hold4->reserve_id, $hold5->reserve_id ] ); |
| 3429 |
is( $patron_hold_groups->count, 2, 'Patron has two hold groups' ); |
| 3430 |
|
| 3431 |
my $second_hold_group = $patron->hold_groups->as_list->[1]; |
| 3432 |
is( $second_hold_group->visual_hold_group_id, 2, 'Visual hold group id is 2' ); |
| 3433 |
is( |
| 3434 |
$second_hold_group->hold_group_id, $hold4->get_from_storage->hold_group_id, |
| 3435 |
'hold4 added to second hold_group' |
| 3436 |
); |
| 3437 |
is( |
| 3438 |
$second_hold_group->hold_group_id, $hold5->get_from_storage->hold_group_id, |
| 3439 |
'hold5 added to second hold_group' |
| 3440 |
); |
| 3441 |
|
| 3442 |
$hold3->get_from_storage->fill(); |
| 3443 |
is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one hold group again' ); |
| 3444 |
|
| 3445 |
$hold4->get_from_storage->cancel(); |
| 3446 |
is( $patron->get_from_storage->hold_groups->count, 0, 'Patron does not have any hold groups again' ); |
| 3447 |
|
| 3448 |
# Create 3rd hold group |
| 3449 |
$patron->create_hold_group( [ $hold5->reserve_id, $hold6->reserve_id ] ); |
| 3450 |
my $third_hold_group = $patron->hold_groups->as_list->[0]; |
| 3451 |
is( $third_hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); |
| 3452 |
|
| 3453 |
$schema->storage->txn_rollback; |
| 3454 |
}; |