|
Lines 571-577
subtest 'request_transfer' => sub {
Link Here
|
| 571 |
}; |
571 |
}; |
| 572 |
|
572 |
|
| 573 |
subtest 'deletion' => sub { |
573 |
subtest 'deletion' => sub { |
| 574 |
plan tests => 12; |
574 |
plan tests => 13; |
| 575 |
|
575 |
|
| 576 |
$schema->storage->txn_begin; |
576 |
$schema->storage->txn_begin; |
| 577 |
|
577 |
|
|
Lines 606-622
subtest 'deletion' => sub {
Link Here
|
| 606 |
C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
606 |
C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
| 607 |
|
607 |
|
| 608 |
is( |
608 |
is( |
| 609 |
$item->safe_to_delete, |
609 |
@{$item->safe_to_delete->messages}[0]->message, |
| 610 |
'book_on_loan', |
610 |
'book_on_loan', |
| 611 |
'Koha::Item->safe_to_delete reports item on loan', |
611 |
'Koha::Item->safe_to_delete reports item on loan', |
| 612 |
); |
612 |
); |
| 613 |
|
613 |
|
| 614 |
is( |
614 |
is( |
| 615 |
$item->safe_delete, |
615 |
@{$item->safe_to_delete->messages}[0]->message, |
| 616 |
'book_on_loan', |
616 |
'book_on_loan', |
| 617 |
'item that is on loan cannot be deleted', |
617 |
'item that is on loan cannot be deleted', |
| 618 |
); |
618 |
); |
| 619 |
|
619 |
|
|
|
620 |
ok( |
| 621 |
! $item->safe_to_delete, |
| 622 |
'Koha::Item->safe_to_delete shows item NOT safe to delete' |
| 623 |
); |
| 624 |
|
| 620 |
AddReturn( $item->barcode, $library->branchcode ); |
625 |
AddReturn( $item->barcode, $library->branchcode ); |
| 621 |
|
626 |
|
| 622 |
# book_reserved is tested in t/db_dependent/Reserves.t |
627 |
# book_reserved is tested in t/db_dependent/Reserves.t |
|
Lines 626-638
subtest 'deletion' => sub {
Link Here
|
| 626 |
my $item_2 = $builder->build_sample_item({ library => $library_2->branchcode }); |
631 |
my $item_2 = $builder->build_sample_item({ library => $library_2->branchcode }); |
| 627 |
|
632 |
|
| 628 |
is( |
633 |
is( |
| 629 |
$item_2->safe_to_delete, |
634 |
@{$item_2->safe_to_delete->messages}[0]->message, |
| 630 |
'not_same_branch', |
635 |
'not_same_branch', |
| 631 |
'Koha::Item->safe_to_delete reports IndependentBranches restriction', |
636 |
'Koha::Item->safe_to_delete reports IndependentBranches restriction', |
| 632 |
); |
637 |
); |
| 633 |
|
638 |
|
| 634 |
is( |
639 |
is( |
| 635 |
$item_2->safe_delete, |
640 |
@{$item_2->safe_to_delete->messages}[0]->message, |
| 636 |
'not_same_branch', |
641 |
'not_same_branch', |
| 637 |
'IndependentBranches prevents deletion at another branch', |
642 |
'IndependentBranches prevents deletion at another branch', |
| 638 |
); |
643 |
); |
|
Lines 646-658
subtest 'deletion' => sub {
Link Here
|
| 646 |
|
651 |
|
| 647 |
$item->discard_changes; |
652 |
$item->discard_changes; |
| 648 |
is( |
653 |
is( |
| 649 |
$item->safe_to_delete, |
654 |
@{$item->safe_to_delete->messages}[0]->message, |
| 650 |
'linked_analytics', |
655 |
'linked_analytics', |
| 651 |
'Koha::Item->safe_to_delete reports linked analytics', |
656 |
'Koha::Item->safe_to_delete reports linked analytics', |
| 652 |
); |
657 |
); |
| 653 |
|
658 |
|
| 654 |
is( |
659 |
is( |
| 655 |
$item->safe_delete, |
660 |
@{$item->safe_to_delete->messages}[0]->message, |
| 656 |
'linked_analytics', |
661 |
'linked_analytics', |
| 657 |
'Linked analytics prevents deletion of item', |
662 |
'Linked analytics prevents deletion of item', |
| 658 |
); |
663 |
); |
|
Lines 661-675
subtest 'deletion' => sub {
Link Here
|
| 661 |
|
666 |
|
| 662 |
{ # last_item_for_hold |
667 |
{ # last_item_for_hold |
| 663 |
C4::Reserves::AddReserve({ branchcode => $patron->branchcode, borrowernumber => $patron->borrowernumber, biblionumber => $item->biblionumber }); |
668 |
C4::Reserves::AddReserve({ branchcode => $patron->branchcode, borrowernumber => $patron->borrowernumber, biblionumber => $item->biblionumber }); |
| 664 |
is( $item->safe_to_delete, 'last_item_for_hold', 'Item cannot be deleted if a biblio-level is placed on the biblio and there is only 1 item attached to the biblio' ); |
669 |
is( |
| 665 |
|
670 |
@{$item->safe_to_delete->messages}[0]->message, |
|
|
671 |
'last_item_for_hold', |
| 672 |
'Item cannot be deleted if a biblio-level is placed on the biblio and there is only 1 item attached to the biblio' |
| 673 |
); |
| 666 |
# With another item attached to the biblio, the item can be deleted |
674 |
# With another item attached to the biblio, the item can be deleted |
| 667 |
$builder->build_sample_item({ biblionumber => $item->biblionumber }); |
675 |
$builder->build_sample_item({ biblionumber => $item->biblionumber }); |
| 668 |
} |
676 |
} |
| 669 |
|
677 |
|
| 670 |
is( |
678 |
ok( |
| 671 |
$item->safe_to_delete, |
679 |
$item->safe_to_delete, |
| 672 |
1, |
|
|
| 673 |
'Koha::Item->safe_to_delete shows item safe to delete' |
680 |
'Koha::Item->safe_to_delete shows item safe to delete' |
| 674 |
); |
681 |
); |
| 675 |
|
682 |
|
| 676 |
- |
|
|