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 = new CGI;
407
    $query = new CGI;
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 = new Test::MockModule('C4::Context');
667
    my $module = new Test::MockModule('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 (-2 / +39 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 63;
20
use Test::More tests => 64;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1075-1080 subtest 'RevertWaitingStatus' => sub { Link Here
1075
    );
1075
    );
1076
};
1076
};
1077
1077
1078
subtest 'AllowHoldOnPatronPossession test' => sub {
1079
1080
    plan tests => 4;
1081
1082
    # Create the items and patrons we need
1083
    my $biblio = $builder->build_sample_biblio();
1084
    my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } });
1085
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype });
1086
    my $patron = $builder->build_object({ class => "Koha::Patrons",
1087
                                          value => { branchcode => $item->homebranch }});
1088
1089
    C4::Circulation::AddIssue($patron->unblessed,
1090
                              $item->barcode);
1091
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 0);
1092
1093
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1094
                                       $item->biblionumber)->{status},
1095
       'itemAlreadyOnLoan',
1096
       'Patron cannot place hold on a book loaned to itself');
1097
1098
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1099
                                       $item->itemnumber)->{status},
1100
       'itemAlreadyOnLoan',
1101
       'Patron cannot place hold on an item loaned to itself');
1102
1103
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1);
1104
1105
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1106
                                       $item->biblionumber)->{status},
1107
       'OK',
1108
       'Patron can place hold on a book loaned to itself');
1109
1110
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1111
                                       $item->itemnumber)->{status},
1112
       'OK',
1113
       'Patron can place hold on an item loaned to itself');
1114
};
1115
1078
sub count_hold_print_messages {
1116
sub count_hold_print_messages {
1079
    my $message_count = $dbh->selectall_arrayref(q{
1117
    my $message_count = $dbh->selectall_arrayref(q{
1080
        SELECT COUNT(*)
1118
        SELECT COUNT(*)
1081
- 

Return to bug 22806