Lines 1287-1293
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1287 |
plan tests => 8; |
1287 |
plan tests => 8; |
1288 |
|
1288 |
|
1289 |
my $library = $builder->build( { source => 'Branch' } ); |
1289 |
my $library = $builder->build( { source => 'Branch' } ); |
1290 |
my $patron = $builder->build( { source => 'Borrower' } ); |
1290 |
my $patron = $builder->build( { source => 'Borrower', value => { gonenoaddress => undef, lost => undef, debarred => undef, borrowernotes => "" } } ); |
1291 |
|
1291 |
|
1292 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1292 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
1293 |
my $item_1 = $builder->build( |
1293 |
my $item_1 = $builder->build( |
Lines 1298-1303
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1298 |
notforloan => 0, |
1298 |
notforloan => 0, |
1299 |
itemlost => 0, |
1299 |
itemlost => 0, |
1300 |
withdrawn => 0, |
1300 |
withdrawn => 0, |
|
|
1301 |
restricted => 0, |
1301 |
biblionumber => $biblioitem_1->{biblionumber} |
1302 |
biblionumber => $biblioitem_1->{biblionumber} |
1302 |
} |
1303 |
} |
1303 |
} |
1304 |
} |
Lines 1311-1316
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1311 |
notforloan => 0, |
1312 |
notforloan => 0, |
1312 |
itemlost => 0, |
1313 |
itemlost => 0, |
1313 |
withdrawn => 0, |
1314 |
withdrawn => 0, |
|
|
1315 |
restricted => 0, |
1314 |
biblionumber => $biblioitem_2->{biblionumber} |
1316 |
biblionumber => $biblioitem_2->{biblionumber} |
1315 |
} |
1317 |
} |
1316 |
} |
1318 |
} |
Lines 1324-1348
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
1324 |
|
1326 |
|
1325 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
1327 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); |
1326 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1328 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1327 |
is( keys(%$error) + keys(%$alerts), 0 ); |
1329 |
is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert ' . keys(%$error) . ' ' . keys(%$alerts) ); |
1328 |
is( $question->{USERBLOCKEDOVERDUE}, 1 ); |
1330 |
is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); |
1329 |
|
1331 |
|
1330 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
1332 |
t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); |
1331 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1333 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1332 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1334 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); |
1333 |
is( $error->{USERBLOCKEDOVERDUE}, 1 ); |
1335 |
is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); |
1334 |
|
1336 |
|
1335 |
# Patron cannot issue item_1, they are debarred |
1337 |
# Patron cannot issue item_1, they are debarred |
1336 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
1338 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
1337 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); |
1339 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber}, expiration => $tomorrow } ); |
1338 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1340 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1339 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1341 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); |
1340 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ) ); |
1342 |
is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); |
1341 |
|
1343 |
|
1342 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); |
1344 |
Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->{borrowernumber} } ); |
1343 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1345 |
( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); |
1344 |
is( keys(%$question) + keys(%$alerts), 0 ); |
1346 |
is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . keys(%$question) . ' ' . keys(%$alerts) ); |
1345 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31' ); |
1347 |
is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); |
1346 |
}; |
1348 |
}; |
1347 |
|
1349 |
|
1348 |
subtest 'MultipleReserves' => sub { |
1350 |
subtest 'MultipleReserves' => sub { |
1349 |
- |
|
|