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

(-)a/t/db_dependent/Koha/Checkouts.t (-10 / +43 lines)
Lines 262-302 subtest 'Koha::Old::Checkouts->filter_by_todays_checkins' => sub { Link Here
262
$schema->storage->txn_rollback;
262
$schema->storage->txn_rollback;
263
263
264
subtest 'automatic_checkin' => sub {
264
subtest 'automatic_checkin' => sub {
265
    plan tests => 6;
265
266
    plan tests => 9;
266
267
267
    $schema->storage->txn_begin;
268
    $schema->storage->txn_begin;
268
269
269
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
270
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
270
271
271
    my $due_ac_item =
272
    my $due_ac_item =
272
      $builder->build_sample_item( { homebranch => $patron->branchcode } );
273
      $builder->build_sample_item(
274
        { homebranch => $patron->branchcode, itemlost => 0 } );
273
    my $ac_item =
275
    my $ac_item =
274
      $builder->build_sample_item( { homebranch => $patron->branchcode } );
276
      $builder->build_sample_item(
277
        { homebranch => $patron->branchcode, itemlost => 0 } );
278
    my $odue_ac_item =
279
      $builder->build_sample_item(
280
        { homebranch => $patron->branchcode, itemlost => 0 } );
275
    my $normal_item =
281
    my $normal_item =
276
      $builder->build_sample_item( { homebranch => $patron->branchcode } );
282
      $builder->build_sample_item(
283
        { homebranch => $patron->branchcode, itemlost => 0 } );
277
284
278
    $due_ac_item->itemtype->automatic_checkin(1)->store;
285
    $due_ac_item->itemtype->automatic_checkin(1)->store;
286
    $odue_ac_item->itemtype->automatic_checkin(1)->store;
279
    $ac_item->itemtype->automatic_checkin(1)->store;
287
    $ac_item->itemtype->automatic_checkin(1)->store;
280
    $normal_item->itemtype->automatic_checkin(0)->store;
288
    $normal_item->itemtype->automatic_checkin(0)->store;
281
289
282
    my $current_date = dt_from_string;
290
    my $today     = dt_from_string;
291
    my $tomorrow  = dt_from_string->add( days => 1 );
292
    my $yesterday = dt_from_string->subtract( days => 1 );
283
293
284
    # due checkout for automatic checkin
294
    # Checkout do for automatic checkin
285
    my $checkout_due_aci = Koha::Checkout->new(
295
    my $checkout_due_aci = Koha::Checkout->new(
286
        {
296
        {
287
            borrowernumber => $patron->borrowernumber,
297
            borrowernumber => $patron->borrowernumber,
288
            itemnumber     => $due_ac_item->itemnumber,
298
            itemnumber     => $due_ac_item->itemnumber,
289
            branchcode     => $patron->branchcode,
299
            branchcode     => $patron->branchcode,
290
            date_due       => $current_date,
300
            date_due       => $today,
301
        }
302
    )->store;
303
304
    # Checkout not due for automatic checkin
305
    my $checkout_odue_aci = Koha::Checkout->new(
306
        {
307
            borrowernumber => $patron->borrowernumber,
308
            itemnumber     => $odue_ac_item->itemnumber,
309
            branchcode     => $patron->branchcode,
310
            date_due       => $yesterday
291
        }
311
        }
292
    )->store;
312
    )->store;
293
313
294
    # in time checkout for automatic checkin
314
    # Checkout not due for automatic checkin
295
    my $checkout_aci = Koha::Checkout->new(
315
    my $checkout_aci = Koha::Checkout->new(
296
        {
316
        {
297
            borrowernumber => $patron->borrowernumber,
317
            borrowernumber => $patron->borrowernumber,
298
            itemnumber     => $ac_item->itemnumber,
318
            itemnumber     => $ac_item->itemnumber,
299
            branchcode     => $patron->branchcode,
319
            branchcode     => $patron->branchcode,
320
            date_due       => $tomorrow
300
        }
321
        }
301
    )->store;
322
    )->store;
302
323
Lines 306-312 subtest 'automatic_checkin' => sub { Link Here
306
            borrowernumber => $patron->borrowernumber,
327
            borrowernumber => $patron->borrowernumber,
307
            itemnumber     => $normal_item->itemnumber,
328
            itemnumber     => $normal_item->itemnumber,
308
            branchcode     => $patron->branchcode,
329
            branchcode     => $patron->branchcode,
309
            date_due       => $current_date,
330
            date_due       => $today,
310
        }
331
        }
311
    )->store;
332
    )->store;
312
333
Lines 325-330 subtest 'automatic_checkin' => sub { Link Here
325
        'checkout for due_ac_item exists'
346
        'checkout for due_ac_item exists'
326
    );
347
    );
327
348
349
    $searched = Koha::Checkouts->find( $checkout_odue_aci->issue_id );
350
    is(
351
        $searched->issue_id,
352
        $checkout_odue_aci->issue_id,
353
        'checkout for odue_ac_item exists'
354
    );
355
328
    Koha::Checkouts->automatic_checkin;
356
    Koha::Checkouts->automatic_checkin;
329
357
330
    $searched = Koha::Checkouts->find( $checkout_ni->issue_id );
358
    $searched = Koha::Checkouts->find( $checkout_ni->issue_id );
Lines 338-342 subtest 'automatic_checkin' => sub { Link Here
338
    $searched = Koha::Checkouts->find( $checkout_due_aci->issue_id );
366
    $searched = Koha::Checkouts->find( $checkout_due_aci->issue_id );
339
    is( $searched, undef, 'checkout for due_ac_item doesn\'t exist anymore' );
367
    is( $searched, undef, 'checkout for due_ac_item doesn\'t exist anymore' );
340
368
369
    $searched = Koha::Checkouts->find( $checkout_odue_aci->issue_id );
370
    is( $searched, undef, 'checkout for odue_ac_item doesn\'t exist anymore' );
371
372
    $searched = Koha::Old::Checkouts->find( $checkout_odue_aci->issue_id );
373
    is( dt_from_string($searched->returndate), $yesterday, 'old checkout for odue_ac_item has the right return date' );
374
341
    $schema->storage->txn_rollback;
375
    $schema->storage->txn_rollback;
342
}
376
}
343
- 

Return to bug 23207