Lines 22-28
use C4::SIP::ILS::Transaction::Hold;
Link Here
|
22 |
use C4::SIP::ILS::Transaction::Checkout; |
22 |
use C4::SIP::ILS::Transaction::Checkout; |
23 |
use C4::SIP::ILS::Transaction::Checkin; |
23 |
use C4::SIP::ILS::Transaction::Checkin; |
24 |
|
24 |
|
25 |
use C4::Reserves qw( AddReserve ModReserve ModReserveAffect RevertWaitingStatus ); |
25 |
use C4::Reserves qw( AddReserve ModReserve ModReserveAffect RevertWaitingStatus ); |
|
|
26 |
use C4::Circulation qw( AddReturn ); |
26 |
use Koha::CirculationRules; |
27 |
use Koha::CirculationRules; |
27 |
use Koha::Item::Transfer; |
28 |
use Koha::Item::Transfer; |
28 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
29 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
Lines 1055-1061
subtest do_checkout_with_noblock => sub {
Link Here
|
1055 |
}; |
1056 |
}; |
1056 |
|
1057 |
|
1057 |
subtest do_checkout_with_holds => sub { |
1058 |
subtest do_checkout_with_holds => sub { |
1058 |
plan tests => 7; |
1059 |
plan tests => 10; |
1059 |
|
1060 |
|
1060 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1061 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1061 |
my $patron = $builder->build_object( |
1062 |
my $patron = $builder->build_object( |
Lines 1103-1131
subtest do_checkout_with_holds => sub {
Link Here
|
1103 |
$sip_item, "Item assigned to transaction" |
1104 |
$sip_item, "Item assigned to transaction" |
1104 |
); |
1105 |
); |
1105 |
|
1106 |
|
1106 |
# Test attached holds |
1107 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '' ); |
|
|
1108 |
|
1109 |
# Test attached holds with no hold statuses allowed to check out |
1107 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) |
1110 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) |
1108 |
my $hold = Koha::Holds->find($reserve); |
1111 |
my $hold = Koha::Holds->find($reserve); |
1109 |
$co_transaction->do_checkout(); |
1112 |
$co_transaction->do_checkout(); |
1110 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)' ); |
1113 |
is( |
|
|
1114 |
$patron->checkouts->count, 0, |
1115 |
'Checkout was not done due to attached hold (W) and AllowItemsOnHoldCheckoutSIP' |
1116 |
); |
1111 |
|
1117 |
|
1112 |
$hold->set_transfer; |
1118 |
$hold->set_transfer; |
1113 |
$co_transaction->do_checkout(); |
1119 |
$co_transaction->do_checkout(); |
1114 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)' ); |
1120 |
is( |
|
|
1121 |
$patron->checkouts->count, 0, |
1122 |
'Checkout was not done due to attached hold (T) and AllowItemsOnHoldCheckoutSIP' |
1123 |
); |
1115 |
|
1124 |
|
1116 |
$hold->set_processing; |
1125 |
$hold->set_processing; |
1117 |
$co_transaction->do_checkout(); |
1126 |
$co_transaction->do_checkout(); |
1118 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)' ); |
1127 |
is( |
|
|
1128 |
$patron->checkouts->count, 0, |
1129 |
'Checkout was not done due to attached hold (P) and AllowItemsOnHoldCheckoutSIP' |
1130 |
); |
1119 |
|
1131 |
|
1120 |
# Test non-attached holds |
1132 |
# Test non-attached holds |
1121 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); |
1133 |
C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); |
1122 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '0' ); |
1134 |
|
|
|
1135 |
$co_transaction->do_checkout(); |
1136 |
is( |
1137 |
$patron->checkouts->count, 0, |
1138 |
'Checkout with non-attached hold refused due to hold and AllowItemsOnHoldCheckoutSIP' |
1139 |
); |
1140 |
|
1141 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', 'pending,processing,transferred,waiting' ); |
1142 |
|
1123 |
$co_transaction->do_checkout(); |
1143 |
$co_transaction->do_checkout(); |
1124 |
is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP' ); |
1144 |
is( |
|
|
1145 |
$patron->checkouts->count, 1, |
1146 |
'Checkout with non-attached hold allowed due to hold and AllowItemsOnHoldCheckoutSIP' |
1147 |
); |
1125 |
|
1148 |
|
1126 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '1' ); |
1149 |
# Test attached holds with all hold statuses allowed to check out |
|
|
1150 |
AddReturn( $item->barcode, $library->branchcode ); |
1151 |
$hold->set_waiting; |
1152 |
$co_transaction->do_checkout(); |
1153 |
is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (W) due to AllowItemsOnHoldCheckoutSIP' ); |
1154 |
|
1155 |
AddReturn( $item->barcode, $library->branchcode ); |
1156 |
$hold->set_transfer; |
1157 |
$co_transaction->do_checkout(); |
1158 |
is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (T) due to AllowItemsOnHoldCheckoutSIP' ); |
1159 |
|
1160 |
AddReturn( $item->barcode, $library->branchcode ); |
1161 |
$hold->set_processing; |
1127 |
$co_transaction->do_checkout(); |
1162 |
$co_transaction->do_checkout(); |
1128 |
is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP' ); |
1163 |
is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (P) due to AllowItemsOnHoldCheckoutSIP' ); |
1129 |
}; |
1164 |
}; |
1130 |
|
1165 |
|
1131 |
subtest checkin_lost => sub { |
1166 |
subtest checkin_lost => sub { |
1132 |
- |
|
|