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

(-)a/t/db_dependent/SIP/Message.t (-2 / +74 lines)
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
        source => 'Borrower',
1318
        value  => {
1319
            password => hash_password( PATRON_PW ),
1320
        },
1321
    });
1322
    my $card1 = $patron1->{cardnumber};
1323
    my $sip_patron1 = C4::SIP::ILS::Patron->new( $card1 );
1324
    my $patron_category = $sip_patron1->ptype();
1325
    $findpatron = $sip_patron1;
1326
    my $item_object_1 = $builder->build_sample_item({
1327
        damaged => 0,
1328
        withdrawn => 0,
1329
        itemlost => 0,
1330
        restricted => 0,
1331
        homebranch => $branchcode,
1332
        holdingbranch => $branchcode,
1333
    });
1334
    my $item_object_2 = $builder->build_sample_item({
1335
        damaged => 1,
1336
        withdrawn => 0,
1337
        itemlost => 0,
1338
        restricted => 0,
1339
        homebranch => $branchcode,
1340
        holdingbranch => $branchcode,
1341
    });
1342
1343
    my $mockILS = $mocks->{ils};
1344
    my $server = { ils => $mockILS, account => {} };
1345
    $mockILS->mock( 'institution', sub { $branchcode; } );
1346
    $mockILS->mock( 'supports', sub { return; } );
1347
    $mockILS->mock( 'renew_all', sub {
1348
        shift;
1349
        return C4::SIP::ILS->renew_all(@_);
1350
    });
1351
    my $today = dt_from_string;
1352
    t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 });
1353
1354
    my $issue_1 = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object_1->itemnumber })->store;
1355
    my $issue_2 = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object_2->itemnumber })->store;
1356
1357
    my $siprequest = RENEW_ALL . siprequestdate($today) .
1358
    FID_INST_ID . $branchcode . '|'.
1359
    FID_PATRON_ID . $sip_patron1->id . '|' .
1360
    FID_TERMINAL_PWD . 'ignored' . '|';
1361
1362
    undef $response;
1363
    my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
1364
    $msg->handle_renew_all( $server );
1365
    isnt( index($response, "BM" . $item_object_1->barcode), -1, "Found corrent BM for item renewed successfully" );
1366
    isnt( index($response, "BN" . $item_object_2->barcode), -1, "Found corrent BN for item not renewed" );
1367
    is( index($response, "C4::SIP::SIPServer" . $item_object_2->barcode), -1, "String 'C4::SIP::SIPServer' not found in reponse ( Bug 35461 )" );
1368
1369
}
1370
1298
sub test_renew_desensitize {
1371
sub test_renew_desensitize {
1299
    my $builder = t::lib::TestBuilder->new();
1372
    my $builder = t::lib::TestBuilder->new();
1300
    my $branchcode  = $builder->build({ source => 'Branch' })->{branchcode};
1373
    my $branchcode  = $builder->build({ source => 'Branch' })->{branchcode};
1301
- 

Return to bug 35461