|
Lines 214-220
subtest 'bundle_host tests' => sub {
Link Here
|
| 214 |
}; |
214 |
}; |
| 215 |
|
215 |
|
| 216 |
subtest 'add_to_bundle tests' => sub { |
216 |
subtest 'add_to_bundle tests' => sub { |
| 217 |
plan tests => 11; |
217 |
plan tests => 12; |
| 218 |
|
218 |
|
| 219 |
$schema->storage->txn_begin; |
219 |
$schema->storage->txn_begin; |
| 220 |
|
220 |
|
|
Lines 263-268
subtest 'add_to_bundle tests' => sub {
Link Here
|
| 263 |
'Koha::Exceptions::Item::Bundle::IsBundle', |
263 |
'Koha::Exceptions::Item::Bundle::IsBundle', |
| 264 |
'Exception thrown if you try to add a bundle host to a bundle item'; |
264 |
'Exception thrown if you try to add a bundle host to a bundle item'; |
| 265 |
|
265 |
|
|
|
266 |
C4::Circulation::AddIssue( $patron->unblessed, $host_item->barcode ); |
| 267 |
throws_ok { $host_item->add_to_bundle($bundle_item2) } |
| 268 |
'Koha::Exceptions::Item::Bundle::BundleIsCheckedOut', |
| 269 |
'Exception thrown if you try to add an item to a checked out bundle'; |
| 270 |
C4::Circulation::AddReturn( $host_item->barcode, $host_item->homebranch ); |
| 271 |
$host_item->discard_changes; |
| 272 |
|
| 266 |
C4::Circulation::AddIssue( $patron->unblessed, $bundle_item2->barcode ); |
273 |
C4::Circulation::AddIssue( $patron->unblessed, $bundle_item2->barcode ); |
| 267 |
throws_ok { $host_item->add_to_bundle($bundle_item2) } |
274 |
throws_ok { $host_item->add_to_bundle($bundle_item2) } |
| 268 |
'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut', |
275 |
'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut', |
|
Lines 286-304
subtest 'add_to_bundle tests' => sub {
Link Here
|
| 286 |
}; |
293 |
}; |
| 287 |
|
294 |
|
| 288 |
subtest 'remove_from_bundle tests' => sub { |
295 |
subtest 'remove_from_bundle tests' => sub { |
| 289 |
plan tests => 3; |
296 |
plan tests => 4; |
| 290 |
|
297 |
|
| 291 |
$schema->storage->txn_begin; |
298 |
$schema->storage->txn_begin; |
| 292 |
|
299 |
|
| 293 |
my $host_item = $builder->build_sample_item(); |
300 |
my $host_item = $builder->build_sample_item(); |
| 294 |
my $bundle_item1 = $builder->build_sample_item({ notforloan => 1 }); |
301 |
my $bundle_item1 = $builder->build_sample_item({ notforloan => 1 }); |
| 295 |
$schema->resultset('ItemBundle') |
302 |
$host_item->add_to_bundle($bundle_item1); |
| 296 |
->create( |
303 |
|
| 297 |
{ host => $host_item->itemnumber, item => $bundle_item1->itemnumber } ); |
304 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
|
305 |
t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } ); |
| 306 |
|
| 307 |
C4::Circulation::AddIssue( $patron->unblessed, $host_item->barcode ); |
| 308 |
throws_ok { $bundle_item1->remove_from_bundle } |
| 309 |
'Koha::Exceptions::Item::Bundle::BundleIsCheckedOut', |
| 310 |
'Exception thrown if you try to add an item to a checked out bundle'; |
| 311 |
my ( $doreturn, $messages, $issue ) = C4::Circulation::AddReturn( $host_item->barcode, $host_item->homebranch ); |
| 312 |
$bundle_item1->discard_changes; |
| 298 |
|
313 |
|
| 299 |
is($bundle_item1->remove_from_bundle(), 1, 'remove_from_bundle returns 1 when item is removed from a bundle'); |
314 |
is($bundle_item1->remove_from_bundle(), 1, 'remove_from_bundle returns 1 when item is removed from a bundle'); |
| 300 |
is($bundle_item1->notforloan, 0, 'remove_from_bundle resets notforloan to 0'); |
315 |
is($bundle_item1->notforloan, 0, 'remove_from_bundle resets notforloan to 0'); |
| 301 |
$bundle_item1 = $bundle_item1->get_from_storage; |
316 |
$bundle_item1->discard_changes; |
| 302 |
is($bundle_item1->remove_from_bundle(), 0, 'remove_from_bundle returns 0 when item is not in a bundle'); |
317 |
is($bundle_item1->remove_from_bundle(), 0, 'remove_from_bundle returns 0 when item is not in a bundle'); |
| 303 |
|
318 |
|
| 304 |
$schema->storage->txn_rollback; |
319 |
$schema->storage->txn_rollback; |
| 305 |
- |
|
|