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

(-)a/t/db_dependent/Koha/Biblio.t (-2 / +68 lines)
Lines 2194-2200 sub host_record { Link Here
2194
}
2194
}
2195
2195
2196
subtest 'check_booking tests' => sub {
2196
subtest 'check_booking tests' => sub {
2197
    plan tests => 5;
2197
    plan tests => 6;
2198
2198
2199
    $schema->storage->txn_begin;
2199
    $schema->storage->txn_begin;
2200
2200
Lines 2309-2313 subtest 'check_booking tests' => sub { Link Here
2309
        "Koha::Item->check_booking takes account of cancelled status in bookings check"
2309
        "Koha::Item->check_booking takes account of cancelled status in bookings check"
2310
    );
2310
    );
2311
2311
2312
    my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } );
2313
    my $library  = $builder->build_object( { class => 'Koha::Libraries' } );
2314
    t::lib::Mocks::mock_userenv( { branchcode => $library->id } );
2315
2316
    # Create a a test biblio with 8 items
2317
    my $new_biblio = $builder->build_object(
2318
        {
2319
            class => 'Koha::Biblios',
2320
            value => { title => 'Test biblio with items' }
2321
        }
2322
    );
2323
    my @new_items;
2324
    for ( 1 .. 8 ) {
2325
        my $item = $builder->build_object(
2326
            {
2327
                class => 'Koha::Items',
2328
                value => {
2329
                    homebranch    => $library->branchcode,
2330
                    holdingbranch => $library->branchcode,
2331
                    biblionumber  => $new_biblio->biblionumber,
2332
                    bookable      => 1
2333
                }
2334
            }
2335
        );
2336
        push @new_items, $item;
2337
    }
2338
2339
    my @item_numbers  = map { $_->itemnumber } @new_items;
2340
    my @item_barcodes = map { $_->barcode } @new_items;
2341
2342
    # Check-out all of those 6 items
2343
    @item_barcodes = splice @item_barcodes, 0, 6;
2344
    for my $item_barcode (@item_barcodes) {
2345
        AddIssue( $patron_1, $item_barcode );
2346
    }
2347
2348
    @item_numbers = splice @item_numbers, 0, 6;
2349
    my @new_bookings;
2350
    for my $itemnumber (@item_numbers) {
2351
        my $booking = $builder->build_object(
2352
            {
2353
                class => 'Koha::Bookings',
2354
                value => {
2355
                    biblio_id  => $new_biblio->biblionumber,
2356
                    item_id    => $itemnumber,
2357
                    start_date => $start_2,
2358
                    end_date   => $end_2,
2359
                    status     => 'new'
2360
                }
2361
            }
2362
        );
2363
        push @new_bookings, $booking;
2364
    }
2365
2366
    # Place a booking on one of the 2 remaining items
2367
    my $item = ( grep { $_->itemnumber ne $new_bookings[0]->item_id } @new_items )[0];
2368
2369
    my $check_booking = $new_biblio->get_from_storage->check_booking(
2370
        {
2371
            start_date => $start_2,
2372
            end_date   => $end_2,
2373
            item_id    => $item->itemnumber
2374
        }
2375
    );
2376
2377
    is( $check_booking, 1, "Koha::Biblio->check_booking returns true when we can book on an item" );
2378
2312
    $schema->storage->txn_rollback;
2379
    $schema->storage->txn_rollback;
2313
};
2380
};
2314
- 

Return to bug 40644