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

(-)a/t/db_dependent/SIP/ILS.t (-1 / +29 lines)
Lines 192-198 subtest cancel_hold => sub { Link Here
192
};
192
};
193
193
194
subtest cancel_waiting_hold => sub {
194
subtest cancel_waiting_hold => sub {
195
    plan tests => 7;
195
    plan tests => 12;
196
196
197
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
197
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
198
    my $patron  = $builder->build_object(
198
    my $patron  = $builder->build_object(
Lines 204-209 subtest cancel_waiting_hold => sub { Link Here
204
        }
204
        }
205
    );
205
    );
206
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } );
206
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } );
207
    t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 0 );
207
208
208
    my $item = $builder->build_sample_item(
209
    my $item = $builder->build_sample_item(
209
        {
210
        {
Lines 252-257 subtest cancel_waiting_hold => sub { Link Here
252
253
253
    is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" );
254
    is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" );
254
    is( $item->holds->count(),         0, "Item has 0 holds remaining" );
255
    is( $item->holds->count(),         0, "Item has 0 holds remaining" );
256
257
    t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 1 );
258
259
    $reserve_id = AddReserve(
260
        {
261
            branchcode     => $library->branchcode,
262
            borrowernumber => $patron->borrowernumber,
263
            biblionumber   => $item->biblio->biblionumber,
264
            itemnumber     => $item->itemnumber,
265
        }
266
    );
267
    $hold = Koha::Holds->find($reserve_id);
268
    ok( $hold, 'Get hold object' );
269
    $hold->update( { found => 'W' } );
270
    $hold->get_from_storage;
271
272
    is( $hold->found, 'W', "Hold was correctly set to waiting." );
273
274
    $transaction = $ils->cancel_hold( $patron->cardnumber, undef, $item->barcode, undef );
275
276
    is(
277
        $transaction->{screen_msg}, "Hold Cancellation Requested.",
278
        "We get a success message when hold cancellation requested"
279
    );
280
281
    is( $item->biblio->holds->count(), 1, "Bib has 1 holds remaining" );
282
    is( $item->holds->count(),         1, "Item has 1 holds remaining" );
255
};
283
};
256
284
257
subtest checkout => sub {
285
subtest checkout => sub {
(-)a/t/db_dependent/SIP/Transaction.t (-2 / +85 lines)
Lines 5-11 Link Here
5
5
6
use Modern::Perl;
6
use Modern::Perl;
7
use Test::NoWarnings;
7
use Test::NoWarnings;
8
use Test::More tests => 20;
8
use Test::More tests => 21;
9
use Test::Warn;
9
use Test::Warn;
10
10
11
use DateTime;
11
use DateTime;
Lines 223-228 subtest cancel_hold => sub { Link Here
223
    is( $item->holds->count(),         0, "Item has 0 holds remaining" );
223
    is( $item->holds->count(),         0, "Item has 0 holds remaining" );
224
};
224
};
225
225
226
subtest cancel_waiting_hold => sub {
227
    plan tests => 14;
228
229
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
230
    my $patron  = $builder->build_object(
231
        {
232
            class => 'Koha::Patrons',
233
            value => {
234
                branchcode => $library->branchcode,
235
            }
236
        }
237
    );
238
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } );
239
    t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 0 );
240
241
    my $item = $builder->build_sample_item(
242
        {
243
            library => $library->branchcode,
244
        }
245
    );
246
247
    Koha::CirculationRules->set_rules(
248
        {
249
            categorycode => $patron->categorycode,
250
            branchcode   => $library->branchcode,
251
            itemtype     => $item->effective_itemtype,
252
            rules        => {
253
                onshelfholds     => 1,
254
                reservesallowed  => 3,
255
                holds_per_record => 3,
256
                issuelength      => 5,
257
                lengthunit       => 'days',
258
            }
259
        }
260
    );
261
262
    my $reserve_id = AddReserve(
263
        {
264
            branchcode     => $library->branchcode,
265
            borrowernumber => $patron->borrowernumber,
266
            biblionumber   => $item->biblio->biblionumber,
267
            itemnumber     => $item->itemnumber,
268
        }
269
    );
270
    is( $item->biblio->holds->count(), 1, "Hold was placed on bib" );
271
    is( $item->holds->count(),         1, "Hold was placed on specific item" );
272
273
    my $sip_patron  = C4::SIP::ILS::Patron->new( $patron->cardnumber );
274
    my $sip_item    = C4::SIP::ILS::Item->new( $item->barcode );
275
    my $transaction = C4::SIP::ILS::Transaction::Hold->new();
276
    is( ref $transaction,                  "C4::SIP::ILS::Transaction::Hold", "New transaction created" );
277
    is( $transaction->patron($sip_patron), $sip_patron,                       "Patron assigned to transaction" );
278
    is( $transaction->item($sip_item),     $sip_item,                         "Item assigned to transaction" );
279
    my $hold = $transaction->drop_hold();
280
    is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" );
281
    is( $item->holds->count(),         0, "Item has 0 holds remaining" );
282
283
    t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 1 );
284
285
    $reserve_id = AddReserve(
286
        {
287
            branchcode     => $library->branchcode,
288
            borrowernumber => $patron->borrowernumber,
289
            biblionumber   => $item->biblio->biblionumber,
290
            itemnumber     => $item->itemnumber,
291
        }
292
    );
293
294
    $hold = Koha::Holds->find($reserve_id);
295
    ok( $hold, 'Get hold object' );
296
    $hold->update( { found => 'W' } );
297
    $hold->get_from_storage;
298
299
    is( $hold->found, 'W', "Hold was correctly set to waiting." );
300
301
    $transaction = C4::SIP::ILS::Transaction::Hold->new();
302
    is( ref $transaction,                  "C4::SIP::ILS::Transaction::Hold", "New transaction created" );
303
    is( $transaction->patron($sip_patron), $sip_patron,                       "Patron assigned to transaction" );
304
    is( $transaction->item($sip_item),     $sip_item,                         "Item assigned to transaction" );
305
    $hold = $transaction->drop_hold();
306
    is( $item->biblio->holds->count(), 1, "Bib has 1 holds remaining" );
307
    is( $item->holds->count(),         1, "Item has 1 holds remaining" );
308
};
309
226
subtest do_hold => sub {
310
subtest do_hold => sub {
227
    plan tests => 8;
311
    plan tests => 8;
228
312
229
- 

Return to bug 38615