|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 60; |
20 |
use Test::More tests => 61; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 739-744
subtest 'ChargeReserveFee tests' => sub {
Link Here
|
| 739 |
is( $line->branchcode, $library->id , "Library id is picked from userenv and stored correctly" ); |
739 |
is( $line->branchcode, $library->id , "Library id is picked from userenv and stored correctly" ); |
| 740 |
}; |
740 |
}; |
| 741 |
|
741 |
|
|
|
742 |
subtest 'reserves.item_level_hold' => sub { |
| 743 |
plan tests => 2; |
| 744 |
|
| 745 |
my $item = $builder->build_sample_item; |
| 746 |
my $patron = $builder->build_object( |
| 747 |
{ |
| 748 |
class => 'Koha::Patrons', |
| 749 |
value => { branchcode => $item->homebranch } |
| 750 |
} |
| 751 |
); |
| 752 |
|
| 753 |
subtest 'item level hold' => sub { |
| 754 |
plan tests => 2; |
| 755 |
my $reserve_id = |
| 756 |
AddReserve( $item->homebranch, $patron->borrowernumber, |
| 757 |
$item->biblionumber, undef, 1, undef, undef, '', '', |
| 758 |
$item->itemnumber ); |
| 759 |
|
| 760 |
my $hold = Koha::Holds->find($reserve_id); |
| 761 |
is( $hold->item_level_hold, 1, 'item_level_hold should be set when AddReserve is called with a specific item' ); |
| 762 |
|
| 763 |
# Mark it waiting |
| 764 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
| 765 |
|
| 766 |
# Revert the waiting status |
| 767 |
C4::Reserves::RevertWaitingStatus( |
| 768 |
{ itemnumber => $item->itemnumber } ); |
| 769 |
|
| 770 |
$hold = Koha::Holds->find($reserve_id); |
| 771 |
|
| 772 |
is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should not be removed when the waiting status is revert' ); |
| 773 |
|
| 774 |
$hold->delete; # cleanup |
| 775 |
}; |
| 776 |
|
| 777 |
subtest 'biblio level hold' => sub { |
| 778 |
plan tests => 3; |
| 779 |
my $reserve_id = AddReserve( $item->homebranch, $patron->borrowernumber, |
| 780 |
$item->biblionumber, undef, 1 ); |
| 781 |
|
| 782 |
my $hold = Koha::Holds->find($reserve_id); |
| 783 |
is( $hold->item_level_hold, 0, 'item_level_hold should not be set when AddReserve is called without a specific item' ); |
| 784 |
|
| 785 |
# Mark it waiting |
| 786 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
| 787 |
|
| 788 |
$hold = Koha::Holds->find($reserve_id); |
| 789 |
is( $hold->itemnumber, $item->itemnumber, 'Itemnumber should be set on hold confirmation' ); |
| 790 |
|
| 791 |
# Revert the waiting status |
| 792 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $item->itemnumber } ); |
| 793 |
|
| 794 |
$hold = Koha::Holds->find($reserve_id); |
| 795 |
is( $hold->itemnumber, undef, 'Itemnumber should be removed when the waiting status is revert' ); |
| 796 |
|
| 797 |
$hold->delete; |
| 798 |
}; |
| 799 |
|
| 800 |
}; |
| 801 |
|
| 742 |
sub count_hold_print_messages { |
802 |
sub count_hold_print_messages { |
| 743 |
my $message_count = $dbh->selectall_arrayref(q{ |
803 |
my $message_count = $dbh->selectall_arrayref(q{ |
| 744 |
SELECT COUNT(*) |
804 |
SELECT COUNT(*) |
| 745 |
- |
|
|