|
Lines 1088-1093
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
| 1088 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1088 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
| 1089 |
}; |
1089 |
}; |
| 1090 |
|
1090 |
|
|
|
1091 |
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { |
| 1092 |
plan tests => 8; |
| 1093 |
|
| 1094 |
my $library = $builder->build( { source => 'Branch' } ); |
| 1095 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 1096 |
|
| 1097 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
| 1098 |
my $item_1 = $builder->build( |
| 1099 |
{ source => 'Item', |
| 1100 |
value => { |
| 1101 |
homebranch => $library->{branchcode}, |
| 1102 |
holdingbranch => $library->{branchcode}, |
| 1103 |
notforloan => 0, |
| 1104 |
itemlost => 0, |
| 1105 |
withdrawn => 0, |
| 1106 |
biblionumber => $biblioitem_1->{biblionumber} |
| 1107 |
} |
| 1108 |
} |
| 1109 |
); |
| 1110 |
my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); |
| 1111 |
my $item_2 = $builder->build( |
| 1112 |
{ source => 'Item', |
| 1113 |
value => { |
| 1114 |
homebranch => $library->{branchcode}, |
| 1115 |
holdingbranch => $library->{branchcode}, |
| 1116 |
notforloan => 0, |
| 1117 |
itemlost => 0, |
| 1118 |
withdrawn => 0, |
| 1119 |
biblionumber => $biblioitem_2->{biblionumber} |
| 1120 |
} |
| 1121 |
} |
| 1122 |
); |
| 1123 |
|
| 1124 |
my ( $error, $question, $alerts ); |
| 1125 |
|
| 1126 |
# Patron cannot issue item_1, he has overdues |
| 1127 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
| 1128 |
my $issue = AddIssue( $patron, $item_1->{barcode}, $yesterday ); # Add an overdue |
| 1129 |
|
| 1130 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
| 1131 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1132 |
is( keys(%$error) + keys(%$alerts), 0 ); |
| 1133 |
is( $question->{USERBLOCKEDOVERDUE}, 1 ); |
| 1134 |
|
| 1135 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
| 1136 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1137 |
is( keys(%$question) + keys(%$alerts), 0 ); |
| 1138 |
is( $error->{USERBLOCKEDOVERDUE}, 1 ); |
| 1139 |
|
| 1140 |
# Patron cannot issue item_1, he is debarred |
| 1141 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
| 1142 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); |
| 1143 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1144 |
is( keys(%$question) + keys(%$alerts), 0 ); |
| 1145 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ) ); |
| 1146 |
|
| 1147 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); |
| 1148 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
| 1149 |
is( keys(%$question) + keys(%$alerts), 0 ); |
| 1150 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); |
| 1151 |
}; |
| 1091 |
|
1152 |
|
| 1092 |
sub set_userenv { |
1153 |
sub set_userenv { |
| 1093 |
my ( $library ) = @_; |
1154 |
my ( $library ) = @_; |
| 1094 |
- |
|
|