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

(-)a/t/db_dependent/SIP/ILS.t (-3 / +64 lines)
Lines 20-35 Link Here
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
22
23
use Test::More tests => 11;
23
use Test::More tests => 12;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
26
use t::lib::Mocks;
27
27
28
use C4::Reserves;
29
use C4::Circulation;
28
use C4::Circulation;
29
use C4::Reserves;
30
use Koha::CirculationRules;
30
use Koha::CirculationRules;
31
use Koha::Database;
31
use Koha::Database;
32
use Koha::DateUtils;
32
use Koha::DateUtils;
33
use Koha::Holds;
33
34
34
BEGIN {
35
BEGIN {
35
    use_ok('C4::SIP::ILS');
36
    use_ok('C4::SIP::ILS');
Lines 125-130 subtest cancel_hold => sub { Link Here
125
    is( $item->holds->count(), 0,  "Item has 0 holds remaining");
126
    is( $item->holds->count(), 0,  "Item has 0 holds remaining");
126
};
127
};
127
128
129
subtest cancel_waiting_hold => sub {
130
    plan tests => 7;
131
132
    my $library = $builder->build_object ({ class => 'Koha::Libraries' });
133
    my $patron = $builder->build_object(
134
        {
135
            class => 'Koha::Patrons',
136
            value => {
137
                branchcode => $library->branchcode,
138
            }
139
        }
140
    );
141
    t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode, flags => 1 });
142
143
    my $item = $builder->build_sample_item({
144
        library       => $library->branchcode,
145
    });
146
147
    Koha::CirculationRules->set_rules(
148
        {
149
            categorycode => $patron->categorycode,
150
            branchcode   => $library->branchcode,
151
            itemtype     => $item->effective_itemtype,
152
            rules        => {
153
                onshelfholds     => 1,
154
                reservesallowed  => 3,
155
                holds_per_record => 3,
156
                issuelength      => 5,
157
                lengthunit       => 'days',
158
            }
159
        }
160
    );
161
162
    my $reserve_id = AddReserve(
163
        {
164
            branchcode     => $library->branchcode,
165
            borrowernumber => $patron->borrowernumber,
166
            biblionumber   => $item->biblio->biblionumber,
167
            itemnumber     => $item->itemnumber,
168
        }
169
    );
170
    is( $item->biblio->holds->count(), 1, "Hold was placed on bib");
171
    is( $item->holds->count(),1,"Hold was placed on specific item");
172
173
    my $hold = Koha::Holds->find( $reserve_id );
174
    ok( $hold, 'Get hold object' );
175
    $hold->update({ found => 'W' });
176
    $hold->get_from_storage;
177
178
    is( $hold->found, 'W', "Hold was correctly set to waiting." );
179
180
    my $ils = C4::SIP::ILS->new({ id => $library->branchcode });
181
    my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
182
    my $transaction = $ils->cancel_hold($patron->cardnumber,undef,$item->barcode,undef);
183
184
    is( $transaction->{screen_msg},"Hold Cancelled.","We get a success message when hold cancelled");
185
186
    is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining");
187
    is( $item->holds->count(), 0,  "Item has 0 holds remaining");
188
};
189
128
subtest checkout => sub {
190
subtest checkout => sub {
129
    plan tests => 4;
191
    plan tests => 4;
130
192
131
- 

Return to bug 28464