Lines 30-36
use Koha::Database;
Link Here
|
30 |
|
30 |
|
31 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
32 |
|
32 |
|
33 |
use Test::More tests => 86; |
33 |
use Test::More tests => 87; |
34 |
|
34 |
|
35 |
BEGIN { |
35 |
BEGIN { |
36 |
use_ok('C4::Circulation'); |
36 |
use_ok('C4::Circulation'); |
Lines 1071-1076
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1071 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1071 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1072 |
}; |
1072 |
}; |
1073 |
|
1073 |
|
|
|
1074 |
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { |
1075 |
plan tests => 8; |
1076 |
|
1077 |
my $library = $builder->build( { source => 'Branch' } ); |
1078 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1079 |
|
1080 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1081 |
my $item_1 = $builder->build( |
1082 |
{ source => 'Item', |
1083 |
value => { |
1084 |
homebranch => $library->{branchcode}, |
1085 |
holdingbranch => $library->{branchcode}, |
1086 |
notforloan => 0, |
1087 |
itemlost => 0, |
1088 |
withdrawn => 0, |
1089 |
biblionumber => $biblioitem_1->{biblionumber} |
1090 |
} |
1091 |
} |
1092 |
); |
1093 |
my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); |
1094 |
my $item_2 = $builder->build( |
1095 |
{ source => 'Item', |
1096 |
value => { |
1097 |
homebranch => $library->{branchcode}, |
1098 |
holdingbranch => $library->{branchcode}, |
1099 |
notforloan => 0, |
1100 |
itemlost => 0, |
1101 |
withdrawn => 0, |
1102 |
biblionumber => $biblioitem_2->{biblionumber} |
1103 |
} |
1104 |
} |
1105 |
); |
1106 |
|
1107 |
my ( $error, $question, $alerts ); |
1108 |
|
1109 |
# Patron cannot issue item_1, he has overdues |
1110 |
my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); |
1111 |
my $issue = AddIssue( $patron, $item_1->{barcode}, $yesterday ); # Add an overdue |
1112 |
|
1113 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
1114 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1115 |
is( keys(%$error) + keys(%$alerts), 0 ); |
1116 |
is( $question->{USERBLOCKEDOVERDUE}, 1 ); |
1117 |
|
1118 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
1119 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1120 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1121 |
is( $error->{USERBLOCKEDOVERDUE}, 1 ); |
1122 |
|
1123 |
# Patron cannot issue item_1, he is debarred |
1124 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
1125 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); |
1126 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1127 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1128 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ) ); |
1129 |
|
1130 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); |
1131 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1132 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1133 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); |
1134 |
}; |
1074 |
|
1135 |
|
1075 |
sub set_userenv { |
1136 |
sub set_userenv { |
1076 |
my ( $library ) = @_; |
1137 |
my ( $library ) = @_; |
1077 |
- |
|
|