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 3118-3120
subtest 'is_anonymous' => sub {
Link Here
|
3118 |
$schema->storage->txn_rollback; |
3118 |
$schema->storage->txn_rollback; |
3119 |
|
3119 |
|
3120 |
}; |
3120 |
}; |
3121 |
- |
3121 |
|
|
|
3122 |
subtest "create_hold_group, hold_groups, visual_hold_group_id tests" => sub { |
3123 |
|
3124 |
plan tests => 13; |
3125 |
|
3126 |
$schema->storage->txn_begin; |
3127 |
|
3128 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
3129 |
my $hold1 = $builder->build_object( |
3130 |
{ |
3131 |
class => 'Koha::Holds', |
3132 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
3133 |
} |
3134 |
); |
3135 |
my $hold2 = $builder->build_object( |
3136 |
{ |
3137 |
class => 'Koha::Holds', |
3138 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
3139 |
} |
3140 |
); |
3141 |
my $hold3 = $builder->build_object( |
3142 |
{ |
3143 |
class => 'Koha::Holds', |
3144 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
3145 |
} |
3146 |
); |
3147 |
|
3148 |
my $hold4 = $builder->build_object( |
3149 |
{ |
3150 |
class => 'Koha::Holds', |
3151 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
3152 |
} |
3153 |
); |
3154 |
my $hold5 = $builder->build_object( |
3155 |
{ |
3156 |
class => 'Koha::Holds', |
3157 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
3158 |
} |
3159 |
); |
3160 |
|
3161 |
my $hold6 = $builder->build_object( |
3162 |
{ |
3163 |
class => 'Koha::Holds', |
3164 |
value => { hold_group_id => undef, found => undef, borrowernumber => $patron->borrowernumber } |
3165 |
} |
3166 |
); |
3167 |
|
3168 |
my $patron_hold_groups = $patron->hold_groups; |
3169 |
is( $patron_hold_groups->count, 0, 'Patron does not have any hold groups' ); |
3170 |
|
3171 |
# Create 1st hold group |
3172 |
$patron->create_hold_group( [ $hold1->reserve_id, $hold2->reserve_id, $hold3->reserve_id ] ); |
3173 |
is( $patron_hold_groups->count, 1, 'Patron has one hold group' ); |
3174 |
|
3175 |
my $hold_group = $patron->hold_groups->as_list->[0]; |
3176 |
is( $hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); |
3177 |
is( $hold_group->hold_group_id, $hold1->get_from_storage->hold_group_id, 'hold1 added to hold_group' ); |
3178 |
is( $hold_group->hold_group_id, $hold2->get_from_storage->hold_group_id, 'hold2 added to hold_group' ); |
3179 |
is( $hold_group->hold_group_id, $hold3->get_from_storage->hold_group_id, 'hold3 added to hold_group' ); |
3180 |
|
3181 |
# Create 2nd hold group |
3182 |
$patron->create_hold_group( [ $hold4->reserve_id, $hold5->reserve_id ] ); |
3183 |
is( $patron_hold_groups->count, 2, 'Patron has two hold groups' ); |
3184 |
|
3185 |
my $second_hold_group = $patron->hold_groups->as_list->[1]; |
3186 |
is( $second_hold_group->visual_hold_group_id, 2, 'Visual hold group id is 2' ); |
3187 |
is( |
3188 |
$second_hold_group->hold_group_id, $hold4->get_from_storage->hold_group_id, |
3189 |
'hold4 added to second hold_group' |
3190 |
); |
3191 |
is( |
3192 |
$second_hold_group->hold_group_id, $hold5->get_from_storage->hold_group_id, |
3193 |
'hold5 added to second hold_group' |
3194 |
); |
3195 |
|
3196 |
$hold3->get_from_storage->fill(); |
3197 |
is( $patron->get_from_storage->hold_groups->count, 1, 'Patron only has one hold group again' ); |
3198 |
|
3199 |
$hold4->get_from_storage->cancel(); |
3200 |
is( $patron->get_from_storage->hold_groups->count, 0, 'Patron does not have any hold groups again' ); |
3201 |
|
3202 |
# Create 3rd hold group |
3203 |
$patron->create_hold_group( [ $hold5->reserve_id, $hold6->reserve_id ] ); |
3204 |
my $third_hold_group = $patron->hold_groups->as_list->[0]; |
3205 |
is( $third_hold_group->visual_hold_group_id, 1, 'Visual hold group id is 1' ); |
3206 |
|
3207 |
$schema->storage->txn_rollback; |
3208 |
}; |