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

(-)a/t/db_dependent/ILSDI_Services.t (-2 / +18 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 417-422 subtest 'Holds test' => sub { Link Here
417
        source => 'Item',
417
        source => 'Item',
418
        value => {
418
        value => {
419
            biblionumber => $biblio3->{biblionumber},
419
            biblionumber => $biblio3->{biblionumber},
420
            barcode => '123456789',
420
            damaged => 0,
421
            damaged => 0,
421
            itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype,
422
            itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype,
422
        }
423
        }
Lines 449-454 subtest 'Holds test' => sub { Link Here
449
    $reply = C4::ILSDI::Services::HoldItem( $query );
450
    $reply = C4::ILSDI::Services::HoldItem( $query );
450
    is( $reply->{code}, 'damaged', "Item is damaged" );
451
    is( $reply->{code}, 'damaged', "Item is damaged" );
451
452
453
    $patron = $builder->build_object({ class => 'Koha::Patrons' });
454
    my $module = new Test::MockModule('C4::Context');
455
    $module->mock('userenv', sub { { patron => $patron } });
456
    my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2);
457
    my $issue = C4::Circulation::AddIssue($patron->unblessed, $item3->{barcode}, $date_due);
458
    t::lib::Mocks::mock_preference( 'AllowHoldsOnPatronsPossessions', '0' );
459
460
    $query->param( 'patron_id', $patron->borrowernumber);
461
    $query->param( 'bib_id', $biblio3->{biblionumber});
462
    $query->param( 'item_id', $item3->{itemnumber});
463
    $reply = C4::ILSDI::Services::HoldItem( $query );
464
465
    is( $reply->{code}, 'itemAlreadyOnLoan', "Patron has issued same book" );
466
    is( $reply->{pickup_location}, undef, "No reserve placed");
467
452
    $schema->storage->txn_rollback;
468
    $schema->storage->txn_rollback;
453
};
469
};
454
470
Lines 716-722 subtest 'GetPatronInfo paginated loans' => sub { Link Here
716
    });
732
    });
717
    my $module = new Test::MockModule('C4::Context');
733
    my $module = new Test::MockModule('C4::Context');
718
    $module->mock('userenv', sub { { branch => $library->branchcode } });
734
    $module->mock('userenv', sub { { branch => $library->branchcode } });
719
    my $date_due = DateTime->now->add(weeks => 2);
735
    my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2);
720
    my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
736
    my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
721
    my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due );
737
    my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due );
722
    my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due);
738
    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 => 62;
20
use Test::More tests => 63;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 1035-1040 subtest 'MoveReserve additional test' => sub { Link Here
1035
1035
1036
};
1036
};
1037
1037
1038
subtest 'AllowHoldOnPatronPossession test' => sub {
1039
1040
    plan tests => 4;
1041
1042
    # Create the items and patrons we need
1043
    my $biblio = $builder->build_sample_biblio();
1044
    my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } });
1045
    my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype });
1046
    my $patron = $builder->build_object({ class => "Koha::Patrons",
1047
                                          value => { branchcode => $item->homebranch }});
1048
1049
    C4::Circulation::AddIssue($patron->unblessed,
1050
                              $item->barcode);
1051
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 0);
1052
1053
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1054
                                       $item->biblionumber)->{status},
1055
       'itemAlreadyOnLoan',
1056
       'Patron cannot place hold on a book loaned to itself');
1057
1058
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1059
                                       $item->itemnumber)->{status},
1060
       'itemAlreadyOnLoan',
1061
       'Patron cannot place hold on an item loaned to itself');
1062
1063
    t::lib::Mocks::mock_preference('AllowHoldsOnPatronsPossessions', 1);
1064
1065
    is(C4::Reserves::CanBookBeReserved($patron->borrowernumber,
1066
                                       $item->biblionumber)->{status},
1067
       'OK',
1068
       'Patron can place hold on a book loaned to itself');
1069
1070
    is(C4::Reserves::CanItemBeReserved($patron->borrowernumber,
1071
                                       $item->itemnumber)->{status},
1072
       'OK',
1073
       'Patron can place hold on an item loaned to itself');
1074
};
1075
1038
sub count_hold_print_messages {
1076
sub count_hold_print_messages {
1039
    my $message_count = $dbh->selectall_arrayref(q{
1077
    my $message_count = $dbh->selectall_arrayref(q{
1040
        SELECT COUNT(*)
1078
        SELECT COUNT(*)
1041
- 

Return to bug 22806