View | Details | Raw Unified | Return to bug 35461
Collapse All | Expand All

(-)a/t/db_dependent/SIP/Message.t (-46 / +73 lines)
Lines 1305-1371 sub test_checkout_desensitize { Link Here
1305
}
1305
}
1306
1306
1307
sub test_renew_all {
1307
sub test_renew_all {
1308
    my $builder = t::lib::TestBuilder->new();
1308
    my $builder    = t::lib::TestBuilder->new();
1309
    my $branchcode  = $builder->build({ source => 'Branch' })->{branchcode};
1309
    my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
1310
    my ( $response, $findpatron );
1310
    my ( $response, $findpatron );
1311
    my $mocks = create_mocks( \$response, \$findpatron, \$branchcode );
1311
    my $mocks = create_mocks( \$response, \$findpatron, \$branchcode );
1312
1312
1313
    t::lib::Mocks::mock_preference('ItemsDeniedRenewal', 'damaged: [1]');
1313
    t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', 'damaged: [1]' );
1314
1314
1315
    # create some data
1315
    # create some data
1316
    my $patron1 = $builder->build({
1316
    my $patron1 = $builder->build(
1317
        source => 'Borrower',
1317
        {
1318
        value  => {
1318
            source => 'Borrower',
1319
            password => hash_password( PATRON_PW ),
1319
            value  => {
1320
        },
1320
                password => hash_password(PATRON_PW),
1321
    });
1321
            },
1322
    my $card1 = $patron1->{cardnumber};
1322
        }
1323
    my $sip_patron1 = C4::SIP::ILS::Patron->new( $card1 );
1323
    );
1324
    my $card1           = $patron1->{cardnumber};
1325
    my $sip_patron1     = C4::SIP::ILS::Patron->new($card1);
1324
    my $patron_category = $sip_patron1->ptype();
1326
    my $patron_category = $sip_patron1->ptype();
1325
    $findpatron = $sip_patron1;
1327
    $findpatron = $sip_patron1;
1326
    my $item_object_1 = $builder->build_sample_item({
1328
    my $item_object_1 = $builder->build_sample_item(
1327
        damaged => 0,
1329
        {
1328
        withdrawn => 0,
1330
            damaged       => 0,
1329
        itemlost => 0,
1331
            withdrawn     => 0,
1330
        restricted => 0,
1332
            itemlost      => 0,
1331
        homebranch => $branchcode,
1333
            restricted    => 0,
1332
        holdingbranch => $branchcode,
1334
            homebranch    => $branchcode,
1333
    });
1335
            holdingbranch => $branchcode,
1334
    my $item_object_2 = $builder->build_sample_item({
1336
        }
1335
        damaged => 1,
1337
    );
1336
        withdrawn => 0,
1338
    my $item_object_2 = $builder->build_sample_item(
1337
        itemlost => 0,
1339
        {
1338
        restricted => 0,
1340
            damaged       => 1,
1339
        homebranch => $branchcode,
1341
            withdrawn     => 0,
1340
        holdingbranch => $branchcode,
1342
            itemlost      => 0,
1341
    });
1343
            restricted    => 0,
1344
            homebranch    => $branchcode,
1345
            holdingbranch => $branchcode,
1346
        }
1347
    );
1342
1348
1343
    my $mockILS = $mocks->{ils};
1349
    my $mockILS = $mocks->{ils};
1344
    my $server = { ils => $mockILS, account => {} };
1350
    my $server  = { ils => $mockILS, account => {} };
1345
    $mockILS->mock( 'institution', sub { $branchcode; } );
1351
    $mockILS->mock( 'institution', sub { $branchcode; } );
1346
    $mockILS->mock( 'supports', sub { return; } );
1352
    $mockILS->mock( 'supports',    sub { return; } );
1347
    $mockILS->mock( 'renew_all', sub {
1353
    $mockILS->mock(
1348
        shift;
1354
        'renew_all',
1349
        return C4::SIP::ILS->renew_all(@_);
1355
        sub {
1350
    });
1356
            shift;
1357
            return C4::SIP::ILS->renew_all(@_);
1358
        }
1359
    );
1351
    my $today = dt_from_string;
1360
    my $today = dt_from_string;
1352
    t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 });
1361
    t::lib::Mocks::mock_userenv( { branchcode => $branchcode, flags => 1 } );
1353
1362
1354
    my $issue_1 = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object_1->itemnumber })->store;
1363
    my $issue_1 = Koha::Checkout->new(
1355
    my $issue_2 = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object_2->itemnumber })->store;
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;
1356
1377
1357
    my $siprequest = RENEW_ALL . siprequestdate($today) .
1378
    my $siprequest =
1358
    FID_INST_ID . $branchcode . '|'.
1379
        RENEW_ALL
1359
    FID_PATRON_ID . $sip_patron1->id . '|' .
1380
      . siprequestdate($today)
1360
    FID_TERMINAL_PWD . 'ignored' . '|';
1381
      . FID_INST_ID
1382
      . $branchcode . '|'
1383
      . FID_PATRON_ID
1384
      . $sip_patron1->id . '|'
1385
      . FID_TERMINAL_PWD
1386
      . 'ignored' . '|';
1361
1387
1362
    undef $response;
1388
    undef $response;
1363
    my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
1389
    my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
1364
    $msg->handle_renew_all( $server );
1390
    $msg->handle_renew_all($server);
1365
    isnt( index($response, "BM" . $item_object_1->barcode), -1, "Found corrent BM for item renewed successfully" );
1391
    isnt( index( $response, "BM" . $item_object_1->barcode ),
1366
    isnt( index($response, "BN" . $item_object_2->barcode), -1, "Found corrent BN for item not renewed" );
1392
        -1, "Found correct BM for item renewed successfully" );
1367
    is( index($response, "C4::SIP::SIPServer" . $item_object_2->barcode), -1, "String 'C4::SIP::SIPServer' not found in reponse ( Bug 35461 )" );
1393
    isnt( index( $response, "BN" . $item_object_2->barcode ),
1368
1394
        -1, "Found correct BN for item not renewed" );
1395
    is( index( $response, "C4::SIP::SIPServer" . $item_object_2->barcode ),
1396
        -1, "String 'C4::SIP::SIPServer' not found in response ( Bug 35461 )" );
1369
}
1397
}
1370
1398
1371
sub test_renew_desensitize {
1399
sub test_renew_desensitize {
1372
- 

Return to bug 35461