|
Lines 2158-2160
subtest 'Remove item from holds queue on checkout' => sub {
Link Here
|
| 2158 |
|
2158 |
|
| 2159 |
$schema->storage->txn_rollback; |
2159 |
$schema->storage->txn_rollback; |
| 2160 |
}; |
2160 |
}; |
| 2161 |
- |
2161 |
|
|
|
2162 |
subtest "Canceled holds should be removed from the holds queue" => sub { |
| 2163 |
|
| 2164 |
plan tests => 2; |
| 2165 |
|
| 2166 |
$schema->storage->txn_begin; |
| 2167 |
|
| 2168 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); |
| 2169 |
t::lib::Mocks::mock_preference( 'UseTransportCostMatrix', 0 ); |
| 2170 |
|
| 2171 |
my $branch1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 2172 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories' } ); |
| 2173 |
my $patron = $builder->build_object( |
| 2174 |
{ |
| 2175 |
class => "Koha::Patrons", |
| 2176 |
value => { |
| 2177 |
branchcode => $branch1->branchcode, |
| 2178 |
categorycode => $category->categorycode |
| 2179 |
} |
| 2180 |
} |
| 2181 |
); |
| 2182 |
|
| 2183 |
my $biblio = $builder->build_sample_biblio(); |
| 2184 |
my $item1 = $builder->build_sample_item( |
| 2185 |
{ |
| 2186 |
biblionumber => $biblio->biblionumber, |
| 2187 |
library => $branch1->branchcode, |
| 2188 |
} |
| 2189 |
); |
| 2190 |
|
| 2191 |
my $reserve_id = AddReserve( |
| 2192 |
{ |
| 2193 |
branchcode => $branch1->branchcode, |
| 2194 |
borrowernumber => $patron->borrowernumber, |
| 2195 |
biblionumber => $biblio->biblionumber, |
| 2196 |
priority => 1, |
| 2197 |
} |
| 2198 |
); |
| 2199 |
|
| 2200 |
C4::HoldsQueue::CreateQueue(); |
| 2201 |
my $rs = $schema->resultset('TmpHoldsqueue'); |
| 2202 |
|
| 2203 |
is( $rs->search( { biblionumber => $biblio->biblionumber } )->count, 1, "Found the hold in the holds queue" ); |
| 2204 |
|
| 2205 |
Koha::Holds->find($reserve_id)->cancel(); |
| 2206 |
|
| 2207 |
is( |
| 2208 |
$rs->search( { biblionumber => $biblio->biblionumber } )->count, 0, |
| 2209 |
"Hold is no longer found in the holds queue after cancellation" |
| 2210 |
); |
| 2211 |
|
| 2212 |
$schema->storage->txn_rollback; |
| 2213 |
}; |