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

(-)a/t/db_dependent/ILSDI_Services.t (-10 / +34 lines)
Lines 300-306 subtest 'LookupPatron test' => sub { Link Here
300
300
301
subtest 'Holds test' => sub {
301
subtest 'Holds test' => sub {
302
302
303
    plan tests => 5;
303
    plan tests => 7;
304
304
305
    $schema->storage->txn_begin;
305
    $schema->storage->txn_begin;
306
306
Lines 371-389 subtest 'Holds test' => sub { Link Here
371
    $reply = C4::ILSDI::Services::HoldItem( $query );
371
    $reply = C4::ILSDI::Services::HoldItem( $query );
372
    is( $reply->{code}, 'tooManyReserves', "Too many reserves" );
372
    is( $reply->{code}, 'tooManyReserves', "Too many reserves" );
373
373
374
    # Adding a holdable item to biblio 3.
374
    my $origin_branch = $builder->build(
375
    my $item3 = $builder->build_sample_item(
376
        {
375
        {
377
            damaged => 0,
376
            source => 'Branch',
377
            value  => {
378
                pickup_location => 1,
379
            }
378
        }
380
        }
379
    );
381
    );
380
382
383
    # Adding a holdable item.
384
    my $item3 = $builder->build_sample_item(
385
       {
386
           barcode => '123456789',
387
           library => $origin_branch->{branchcode}
388
       });
389
381
    my $item4 = $builder->build_sample_item(
390
    my $item4 = $builder->build_sample_item(
382
        {
391
        {
383
            biblionumber => $item3->biblionumber,
392
           biblionumber => $item3->biblionumber,
384
            damaged      => 1,
393
           damaged => 1,
385
        }
394
           library => $origin_branch->{branchcode}
386
    );
395
       });
387
396
388
    Koha::CirculationRules->set_rule(
397
    Koha::CirculationRules->set_rule(
389
        {
398
        {
Lines 397-408 subtest 'Holds test' => sub { Link Here
397
406
398
    $query = CGI->new;
407
    $query = CGI->new;
399
    $query->param( 'patron_id', $patron->{borrowernumber});
408
    $query->param( 'patron_id', $patron->{borrowernumber});
400
    $query->param( 'bib_id', $item3->biblionumber);
409
    $query->param( 'bib_id', $item4->biblionumber);
401
    $query->param( 'item_id', $item4->itemnumber);
410
    $query->param( 'item_id', $item4->itemnumber);
402
411
403
    $reply = C4::ILSDI::Services::HoldItem( $query );
412
    $reply = C4::ILSDI::Services::HoldItem( $query );
404
    is( $reply->{code}, 'damaged', "Item is damaged" );
413
    is( $reply->{code}, 'damaged', "Item is damaged" );
405
414
415
    my $module = new Test::MockModule('C4::Context');
416
    $module->mock('userenv', sub { { patron => $patron } });
417
    my $issue = C4::Circulation::AddIssue($patron, $item3->barcode);
418
    t::lib::Mocks::mock_preference( 'AllowHoldsOnPatronsPossessions', '0' );
419
420
    $query = new CGI;
421
    $query->param( 'patron_id', $patron->{borrowernumber});
422
    $query->param( 'bib_id', $item3->biblionumber);
423
    $query->param( 'item_id', $item3->itemnumber);
424
    $query->param( 'pickup_location', $origin_branch->{branchcode});
425
    $reply = C4::ILSDI::Services::HoldItem( $query );
426
427
    is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" );
428
    is( $reply->{pickup_location}, undef, "No reserve placed");
429
406
    $schema->storage->txn_rollback;
430
    $schema->storage->txn_rollback;
407
};
431
};
408
432
Lines 642-648 subtest 'GetPatronInfo paginated loans' => sub { Link Here
642
    });
666
    });
643
    my $module = Test::MockModule->new('C4::Context');
667
    my $module = Test::MockModule->new('C4::Context');
644
    $module->mock('userenv', sub { { branch => $library->branchcode } });
668
    $module->mock('userenv', sub { { branch => $library->branchcode } });
645
    my $date_due = DateTime->now->add(weeks => 2);
669
    my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2);
646
    my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
670
    my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
647
    my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due );
671
    my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due );
648
    my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due);
672
    my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due);
(-)a/t/db_dependent/Reserves.t (-1 / +37 lines)
Lines 1150-1156 subtest 'CheckReserves additional test' => sub { Link Here
1150
    is( $matched_reserve->{reserve_id},
1150
    is( $matched_reserve->{reserve_id},
1151
        $reserve1->reserve_id, "We got the Transit reserve" );
1151
        $reserve1->reserve_id, "We got the Transit reserve" );
1152
    is( scalar @$possible_reserves, 2, 'We do get both reserves' );
1152
    is( scalar @$possible_reserves, 2, 'We do get both reserves' );
1153
};
1154
1155
subtest 'AllowHoldOnPatronPossession test' => sub {
1156
1157
    plan tests => 4;
1153
1158
1159
    # Create the items and patrons we need
1160
    my $biblio = $builder->build_sample_biblio();
1161
    my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } });
1162
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype });
1163
    my $patron = $builder->build_object({ class => "Koha::Patrons",
1164
                                          value => { branchcode => $item->homebranch }});
1165
1166
    C4::Circulation::AddIssue($patron->unblessed,
1167
                              $item->barcode);
1168
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 0);
1169
1170
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1171
                                       $item->biblionumber)->{status},
1172
       'itemAlreadyOnLoan',
1173
       'Patron cannot place hold on a book loaned to itself');
1174
1175
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1176
                                       $item->itemnumber)->{status},
1177
       'itemAlreadyOnLoan',
1178
       'Patron cannot place hold on an item loaned to itself');
1179
1180
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1);
1181
1182
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1183
                                       $item->biblionumber)->{status},
1184
       'OK',
1185
       'Patron can place hold on a book loaned to itself');
1186
1187
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1188
                                       $item->itemnumber)->{status},
1189
       'OK',
1190
       'Patron can place hold on an item loaned to itself');
1154
};
1191
};
1155
1192
1156
sub count_hold_print_messages {
1193
sub count_hold_print_messages {
1157
- 

Return to bug 22806