|
Lines 21-27
Link Here
|
| 21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 22 |
|
22 |
|
| 23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
| 24 |
use Test::More tests => 17; |
24 |
use Test::More tests => 18; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockObject; |
26 |
use Test::MockObject; |
| 27 |
use Test::MockModule; |
27 |
use Test::MockModule; |
|
Lines 96-101
subtest 'Test renew desensitize' => sub {
Link Here
|
| 96 |
$schema->storage->txn_rollback; |
96 |
$schema->storage->txn_rollback; |
| 97 |
}; |
97 |
}; |
| 98 |
|
98 |
|
|
|
99 |
subtest 'Test renew desensitize' => sub { |
| 100 |
my $schema = Koha::Database->new->schema; |
| 101 |
$schema->storage->txn_begin; |
| 102 |
plan tests => 3; |
| 103 |
$C4::SIP::Sip::protocol_version = 2; |
| 104 |
test_renew_all(); |
| 105 |
$schema->storage->txn_rollback; |
| 106 |
}; |
| 107 |
|
| 99 |
subtest 'Checkin V2' => sub { |
108 |
subtest 'Checkin V2' => sub { |
| 100 |
my $schema = Koha::Database->new->schema; |
109 |
my $schema = Koha::Database->new->schema; |
| 101 |
$schema->storage->txn_begin; |
110 |
$schema->storage->txn_begin; |
|
Lines 1295-1300
sub test_checkout_desensitize {
Link Here
|
| 1295 |
is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" ); |
1304 |
is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" ); |
| 1296 |
} |
1305 |
} |
| 1297 |
|
1306 |
|
|
|
1307 |
sub test_renew_all { |
| 1308 |
my $builder = t::lib::TestBuilder->new(); |
| 1309 |
my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; |
| 1310 |
my ( $response, $findpatron ); |
| 1311 |
my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); |
| 1312 |
|
| 1313 |
t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', 'damaged: [1]' ); |
| 1314 |
|
| 1315 |
# create some data |
| 1316 |
my $patron1 = $builder->build( |
| 1317 |
{ |
| 1318 |
source => 'Borrower', |
| 1319 |
value => { |
| 1320 |
password => hash_password(PATRON_PW), |
| 1321 |
}, |
| 1322 |
} |
| 1323 |
); |
| 1324 |
my $card1 = $patron1->{cardnumber}; |
| 1325 |
my $sip_patron1 = C4::SIP::ILS::Patron->new($card1); |
| 1326 |
my $patron_category = $sip_patron1->ptype(); |
| 1327 |
$findpatron = $sip_patron1; |
| 1328 |
my $item_object_1 = $builder->build_sample_item( |
| 1329 |
{ |
| 1330 |
damaged => 0, |
| 1331 |
withdrawn => 0, |
| 1332 |
itemlost => 0, |
| 1333 |
restricted => 0, |
| 1334 |
homebranch => $branchcode, |
| 1335 |
holdingbranch => $branchcode, |
| 1336 |
} |
| 1337 |
); |
| 1338 |
my $item_object_2 = $builder->build_sample_item( |
| 1339 |
{ |
| 1340 |
damaged => 1, |
| 1341 |
withdrawn => 0, |
| 1342 |
itemlost => 0, |
| 1343 |
restricted => 0, |
| 1344 |
homebranch => $branchcode, |
| 1345 |
holdingbranch => $branchcode, |
| 1346 |
} |
| 1347 |
); |
| 1348 |
|
| 1349 |
my $mockILS = $mocks->{ils}; |
| 1350 |
my $server = { ils => $mockILS, account => {} }; |
| 1351 |
$mockILS->mock( 'institution', sub { $branchcode; } ); |
| 1352 |
$mockILS->mock( 'supports', sub { return; } ); |
| 1353 |
$mockILS->mock( |
| 1354 |
'renew_all', |
| 1355 |
sub { |
| 1356 |
shift; |
| 1357 |
return C4::SIP::ILS->renew_all(@_); |
| 1358 |
} |
| 1359 |
); |
| 1360 |
my $today = dt_from_string; |
| 1361 |
t::lib::Mocks::mock_userenv( { branchcode => $branchcode, flags => 1 } ); |
| 1362 |
|
| 1363 |
my $issue_1 = Koha::Checkout->new( |
| 1364 |
{ |
| 1365 |
branchcode => $branchcode, |
| 1366 |
borrowernumber => $patron1->{borrowernumber}, |
| 1367 |
itemnumber => $item_object_1->itemnumber |
| 1368 |
} |
| 1369 |
)->store; |
| 1370 |
my $issue_2 = Koha::Checkout->new( |
| 1371 |
{ |
| 1372 |
branchcode => $branchcode, |
| 1373 |
borrowernumber => $patron1->{borrowernumber}, |
| 1374 |
itemnumber => $item_object_2->itemnumber |
| 1375 |
} |
| 1376 |
)->store; |
| 1377 |
|
| 1378 |
my $siprequest = |
| 1379 |
RENEW_ALL |
| 1380 |
. siprequestdate($today) |
| 1381 |
. FID_INST_ID |
| 1382 |
. $branchcode . '|' |
| 1383 |
. FID_PATRON_ID |
| 1384 |
. $sip_patron1->id . '|' |
| 1385 |
. FID_TERMINAL_PWD |
| 1386 |
. 'ignored' . '|'; |
| 1387 |
|
| 1388 |
undef $response; |
| 1389 |
my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); |
| 1390 |
$msg->handle_renew_all($server); |
| 1391 |
isnt( |
| 1392 |
index( $response, "BM" . $item_object_1->barcode ), |
| 1393 |
-1, "Found correct BM for item renewed successfully" |
| 1394 |
); |
| 1395 |
isnt( |
| 1396 |
index( $response, "BN" . $item_object_2->barcode ), |
| 1397 |
-1, "Found correct BN for item not renewed" |
| 1398 |
); |
| 1399 |
is( index( $response, "HASH(", ) - 1, "String 'HASH(' not found in reponse ( Bug 35461 )" ); |
| 1400 |
} |
| 1401 |
|
| 1298 |
sub test_renew_desensitize { |
1402 |
sub test_renew_desensitize { |
| 1299 |
my $builder = t::lib::TestBuilder->new(); |
1403 |
my $builder = t::lib::TestBuilder->new(); |
| 1300 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
1404 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 1301 |
- |
|
|