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

(-)a/C4/SIP/ILS.pm (-5 / +4 lines)
Lines 296-306 sub add_hold { Link Here
296
296
297
	my $trans = C4::SIP::ILS::Transaction::Hold->new();
297
	my $trans = C4::SIP::ILS::Transaction::Hold->new();
298
298
299
    $patron = C4::SIP::ILS::Patron->new( $patron_id);
299
    $patron = C4::SIP::ILS::Patron->new( $patron_id );
300
    if (!$patron
300
    if ( !$patron ) {
301
	|| (defined($patron_pwd) && !$patron->check_password($patron_pwd))) {
301
        $trans->screen_msg("Invalid patron barcode.");
302
		$trans->screen_msg("Invalid Patron.");
302
        return $trans;
303
		return $trans;
304
    }
303
    }
305
304
306
	unless ($item = C4::SIP::ILS::Item->new($item_id || $title_id)) {
305
	unless ($item = C4::SIP::ILS::Item->new($item_id || $title_id)) {
(-)a/t/db_dependent/SIP/ILS.t (-2 / +52 lines)
Lines 20-26 Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
22
23
use Test::More tests => 12;
23
use Test::More tests => 13;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
26
use t::lib::Mocks;
Lines 71-76 is( $ils->test_cardnumber_compare( 'A1234', 'a1234' ), Link Here
71
is( $ils->test_cardnumber_compare( 'A1234', 'b1234' ),
71
is( $ils->test_cardnumber_compare( 'A1234', 'b1234' ),
72
    q{}, 'borrower bc test identifies difference' );
72
    q{}, 'borrower bc test identifies difference' );
73
73
74
subtest add_hold => sub {
75
    plan tests => 4;
76
77
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
78
    my $patron = $builder->build_object(
79
        {
80
            class => 'Koha::Patrons',
81
            value => {
82
                branchcode => $library->branchcode,
83
            }
84
        }
85
    );
86
    t::lib::Mocks::mock_userenv(
87
        { branchcode => $library->branchcode, flags => 1 } );
88
89
    my $item = $builder->build_sample_item(
90
        {
91
            library => $library->branchcode,
92
        }
93
    );
94
95
    Koha::CirculationRules->set_rules(
96
        {
97
            categorycode => $patron->categorycode,
98
            branchcode   => $library->branchcode,
99
            itemtype     => $item->effective_itemtype,
100
            rules        => {
101
                onshelfholds     => 1,
102
                reservesallowed  => 3,
103
                holds_per_record => 3,
104
                issuelength      => 5,
105
                lengthunit       => 'days',
106
            }
107
        }
108
    );
109
110
    my $ils = C4::SIP::ILS->new( { id => $library->branchcode } );
111
112
    # Send empty AD segments (i.e. empty string for patron_pwd)
113
    my $transaction = $ils->add_hold( $patron->cardnumber, "", $item->barcode, undef );
114
    isnt(
115
        $transaction->{screen_msg},
116
        'Invalid patron password.',
117
        "Empty password succeeds"
118
    );
119
    ok( $transaction->{ok}, "Transaction returned success");
120
    is( $item->biblio->holds->count(), 1, "Hold was placed on bib");
121
    # FIXME: Should we not allow for item-level holds when we're passed an item barcode...
122
    is( $item->holds->count(),0,"Hold was placed at bib level");
123
};
124
74
subtest cancel_hold => sub {
125
subtest cancel_hold => sub {
75
    plan tests => 6;
126
    plan tests => 6;
76
127
77
- 

Return to bug 27600