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

(-)a/t/db_dependent/HoldsQueue.t (-2 / +68 lines)
Lines 8-19 Link Here
8
8
9
use Modern::Perl;
9
use Modern::Perl;
10
10
11
use Test::More tests => 55;
11
use Test::More tests => 56;
12
use Data::Dumper;
12
use Data::Dumper;
13
13
14
use C4::Calendar;
14
use C4::Calendar;
15
use C4::Context;
15
use C4::Context;
16
use C4::Members;
16
use C4::Members;
17
use C4::Circulation;
17
use Koha::Database;
18
use Koha::Database;
18
use Koha::DateUtils;
19
use Koha::DateUtils;
19
use Koha::Items;
20
use Koha::Items;
Lines 1523-1525 sub dump_records { Link Here
1523
    my ($tablename) = @_;
1524
    my ($tablename) = @_;
1524
    return $dbh->selectall_arrayref("SELECT * from $tablename where borrowernumber = ?", { Slice => {} }, $borrowernumber);
1525
    return $dbh->selectall_arrayref("SELECT * from $tablename where borrowernumber = ?", { Slice => {} }, $borrowernumber);
1525
}
1526
}
1526
- 
1527
1528
subtest 'Remove holds on check-in match' => sub {
1529
    plan tests => 2;
1530
1531
    $schema->storage->txn_begin;
1532
1533
    $dbh->do('DELETE FROM tmp_holdsqueue');
1534
    $dbh->do('DELETE FROM hold_fill_targets');
1535
1536
    my $lib = $builder->build_object( { class => 'Koha::Libraries' } );
1537
1538
    my $patron1 = $builder->build_object(
1539
        {
1540
            class => 'Koha::Patrons',
1541
            value => { branchcode => $lib->branchcode }
1542
        }
1543
    );
1544
    my $patron2 = $builder->build_object(
1545
        {
1546
            class => 'Koha::Patrons',
1547
            value => { branchcode => $lib->branchcode }
1548
        }
1549
    );
1550
1551
    my $item = $builder->build_sample_item(
1552
        { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } );
1553
1554
    t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } );
1555
1556
    AddIssue( $patron1->unblessed, $item->barcode, dt_from_string );
1557
1558
    my $hold_id = AddReserve(
1559
        {
1560
            branchcode     => $item->homebranch,
1561
            borrowernumber => $patron2->borrowernumber,
1562
            biblionumber   => $item->biblionumber,
1563
            itemnumber     => undef,
1564
            priority       => 1
1565
        }
1566
    );
1567
1568
    my $hold = Koha::Holds->find($hold_id);
1569
1570
    AddReturn( $item->barcode, $item->homebranch );
1571
1572
    C4::HoldsQueue::CreateQueue();
1573
1574
    my $sth = $dbh->prepare("SELECT count(*) FROM tmp_holdsqueue");
1575
    $sth->execute();
1576
    my ($count_1) = $sth->fetchrow_array;
1577
1578
    is( $count_1, 1, "Holds queue has one element" );
1579
1580
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string );
1581
1582
    ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0,
1583
        $hold->reserve_id );
1584
1585
    $sth->execute();
1586
    my ($count_2) = $sth->fetchrow_array;
1587
1588
    is( $count_2, 0,
1589
        "Holds queue has no elements, even when queue was not rebuilt" );
1590
1591
    $schema->storage->txn_rollback;
1592
};

Return to bug 24359