Lines 62-76
subtest 'Old version is unchanged' => sub {
Link Here
|
62 |
|
62 |
|
63 |
subtest 'Skip items with waiting holds' => sub { |
63 |
subtest 'Skip items with waiting holds' => sub { |
64 |
|
64 |
|
65 |
plan tests => 6; |
65 |
plan tests => 7; |
66 |
|
66 |
|
67 |
$schema->storage->txn_begin; |
67 |
$schema->storage->txn_begin; |
68 |
|
68 |
|
69 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
69 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
70 |
my $itemtype |
70 |
my $itemtype |
71 |
= $builder->build_object( { class => 'Koha::ItemTypes', value => { rentalcharge => 0 } } ); |
71 |
= $builder->build_object( { class => 'Koha::ItemTypes', value => { rentalcharge => 0 } } ); |
72 |
my $patron = $builder->build_object( |
72 |
my $patron_1 = $builder->build_object( |
73 |
{ class => 'Koha::Patrons', value => { branchcode => $library->id } } ); |
73 |
{ class => 'Koha::Patrons', value => { branchcode => $library->id } } ); |
|
|
74 |
my $patron_2 = $builder->build_object( |
75 |
{ class => 'Koha::Patrons', value => { branchcode => $library->id } } ); |
76 |
|
74 |
|
77 |
|
75 |
my $title_1 = 'Title 1, '; |
78 |
my $title_1 = 'Title 1, '; |
76 |
my $title_2 = 'Title 2, bizzarre one so doesn\'t already exist'; |
79 |
my $title_2 = 'Title 2, bizzarre one so doesn\'t already exist'; |
Lines 112-122
subtest 'Skip items with waiting holds' => sub {
Link Here
|
112 |
is( scalar @{$items_2}, $second_items_count, 'Results and count match' ); |
115 |
is( scalar @{$items_2}, $second_items_count, 'Results and count match' ); |
113 |
is( $first_items_count + 2, $second_items_count, 'Two items added, count makes sense' ); |
116 |
is( $first_items_count + 2, $second_items_count, 'Two items added, count makes sense' ); |
114 |
|
117 |
|
115 |
# Add a waiting hold |
118 |
# Add 2 waiting holds |
116 |
my $reserve_id |
119 |
C4::Reserves::AddReserve( $library->branchcode, $patron_1->borrowernumber, |
117 |
= C4::Reserves::AddReserve( $library->branchcode, $patron->borrowernumber, |
|
|
118 |
$item_1->biblionumber, '', 1, undef, undef, '', "title for fee", |
120 |
$item_1->biblionumber, '', 1, undef, undef, '', "title for fee", |
119 |
$item_1->itemnumber, 'W' ); |
121 |
$item_1->itemnumber, 'W' ); |
|
|
122 |
C4::Reserves::AddReserve( $library->branchcode, $patron_1->borrowernumber, |
123 |
$item_2->biblionumber, '', 1, undef, undef, '', "title for fee", |
124 |
$item_2->itemnumber, undef ); |
125 |
C4::Reserves::AddReserve( $library->branchcode, $patron_2->borrowernumber, |
126 |
$item_2->biblionumber, '', 2, undef, undef, '', "title for fee", |
127 |
$item_2->itemnumber, undef ); |
120 |
|
128 |
|
121 |
my ( $new_items, $new_items_count ) = GetItemsForInventory( { ignore_waiting_holds => 1 } ); |
129 |
my ( $new_items, $new_items_count ) = GetItemsForInventory( { ignore_waiting_holds => 1 } ); |
122 |
is( $new_items_count, $first_items_count + 1, 'Item on hold skipped, count makes sense' ); |
130 |
is( $new_items_count, $first_items_count + 1, 'Item on hold skipped, count makes sense' ); |
Lines 124-129
subtest 'Skip items with waiting holds' => sub {
Link Here
|
124 |
'Item on hold skipped, the other one we added is present' ); |
132 |
'Item on hold skipped, the other one we added is present' ); |
125 |
ok( (none { $_->{title} eq $title_1 } @{$new_items}), |
133 |
ok( (none { $_->{title} eq $title_1 } @{$new_items}), |
126 |
'Item on hold skipped, no one matches' ); |
134 |
'Item on hold skipped, no one matches' ); |
|
|
135 |
is( scalar(@$new_items), $new_items_count, 'total and number of items is the same'); |
127 |
|
136 |
|
128 |
$schema->storage->txn_rollback; |
137 |
$schema->storage->txn_rollback; |
129 |
}; |
138 |
}; |
130 |
- |
|
|