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

(-)a/t/db_dependent/HoldsQueue.t (-2 / +79 lines)
Lines 8-14 Link Here
8
8
9
use Modern::Perl;
9
use Modern::Perl;
10
10
11
use Test::More tests => 63;
11
use Test::More tests => 64;
12
use Data::Dumper;
12
use Data::Dumper;
13
13
14
use C4::Calendar qw( new insert_single_holiday );
14
use C4::Calendar qw( new insert_single_holiday );
Lines 2211-2213 subtest "Canceled holds should be removed from the holds queue" => sub { Link Here
2211
2211
2212
    $schema->storage->txn_rollback;
2212
    $schema->storage->txn_rollback;
2213
};
2213
};
2214
- 
2214
2215
subtest "Test unallocated option" => sub {
2216
2217
    plan tests => 6;
2218
2219
    $schema->storage->txn_begin;
2220
2221
    my $patron = $builder->build_object(
2222
        {
2223
            class => "Koha::Patrons",
2224
        }
2225
    );
2226
    my $patron_2 = $builder->build_object(
2227
        {
2228
            class => "Koha::Patrons",
2229
        }
2230
    );
2231
2232
    my $item1 = $builder->build_sample_item( {} )->store();
2233
2234
    my $item2 = $builder->build_sample_item( {} )->store();
2235
2236
    my $reserve_id = AddReserve(
2237
        {
2238
            branchcode     => $patron->branchcode,
2239
            borrowernumber => $patron->borrowernumber,
2240
            biblionumber   => $item1->biblionumber,
2241
            priority       => 1,
2242
        }
2243
    );
2244
2245
    C4::HoldsQueue::CreateQueue();
2246
2247
    my $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item1->biblionumber } );
2248
    my $hold     = $queue_rs->next;
2249
    is(
2250
        $hold->itemnumber->itemnumber,
2251
        $item1->itemnumber,
2252
        "Picked the item"
2253
    );
2254
2255
    my $timestamp = $hold->timestamp;
2256
2257
    sleep 2;
2258
    C4::HoldsQueue::CreateQueue();
2259
    $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item1->biblionumber } );
2260
    $hold     = $queue_rs->next;
2261
    isnt( $hold->timestamp, $timestamp, "Hold was reallocated when queue fully rebuilt" );
2262
    $timestamp = $hold->timestamp;
2263
2264
    C4::HoldsQueue::CreateQueue( { unallocated => 1 } );
2265
    $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item1->biblionumber } );
2266
    $hold     = $queue_rs->next;
2267
    is( $hold->timestamp, $timestamp, "Previously allocated hold not updated when unallocated passed" );
2268
2269
    my $reserve_id_2 = AddReserve(
2270
        {
2271
            branchcode     => $patron_2->branchcode,
2272
            borrowernumber => $patron_2->borrowernumber,
2273
            biblionumber   => $item2->biblionumber,
2274
            priority       => 1,
2275
        }
2276
    );
2277
    $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item2->biblionumber } );
2278
    $hold     = $queue_rs->next;
2279
    ok( !$hold, "New hold is not allocated to queue before run" );
2280
    C4::HoldsQueue::CreateQueue( { unallocated => 1 } );
2281
    $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item2->biblionumber } );
2282
    $hold     = $queue_rs->next;
2283
    ok( $hold, "New hold is allocated to queue when run for unallocated holds" );
2284
2285
    $queue_rs = $schema->resultset('TmpHoldsqueue')->search( { biblionumber => $item1->biblionumber } );
2286
    $hold     = $queue_rs->next;
2287
    is(
2288
        $hold->timestamp, $timestamp,
2289
        "Previously allocated hold not updated when unallocated passed and others are allocated"
2290
    );
2291
};

Return to bug 32565