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

(-)a/t/db_dependent/HoldsQueue.t (-1 / +67 lines)
Lines 14-19 use Data::Dumper; Link Here
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 1657-1659 sub dump_records { Link Here
1657
    my ($tablename) = @_;
1658
    my ($tablename) = @_;
1658
    return $dbh->selectall_arrayref("SELECT * from $tablename where borrowernumber = ?", { Slice => {} }, $borrowernumber);
1659
    return $dbh->selectall_arrayref("SELECT * from $tablename where borrowernumber = ?", { Slice => {} }, $borrowernumber);
1659
}
1660
}
1660
- 
1661
1662
subtest 'Remove holds on check-in match' => sub {
1663
    plan tests => 2;
1664
1665
    $schema->storage->txn_begin;
1666
1667
    $dbh->do('DELETE FROM tmp_holdsqueue');
1668
    $dbh->do('DELETE FROM hold_fill_targets');
1669
1670
    my $lib = $builder->build_object( { class => 'Koha::Libraries' } );
1671
1672
    my $patron1 = $builder->build_object(
1673
        {
1674
            class => 'Koha::Patrons',
1675
            value => { branchcode => $lib->branchcode }
1676
        }
1677
    );
1678
    my $patron2 = $builder->build_object(
1679
        {
1680
            class => 'Koha::Patrons',
1681
            value => { branchcode => $lib->branchcode }
1682
        }
1683
    );
1684
1685
    my $item = $builder->build_sample_item(
1686
        { homebranch => $lib->branchcode, holdingbranch => $lib->branchcode } );
1687
1688
    t::lib::Mocks::mock_userenv( { branchcode => $lib->branchcode } );
1689
1690
    AddIssue( $patron1->unblessed, $item->barcode, dt_from_string );
1691
1692
    my $hold_id = AddReserve(
1693
        {
1694
            branchcode     => $item->homebranch,
1695
            borrowernumber => $patron2->borrowernumber,
1696
            biblionumber   => $item->biblionumber,
1697
            itemnumber     => undef,
1698
            priority       => 1
1699
        }
1700
    );
1701
1702
    my $hold = Koha::Holds->find($hold_id);
1703
1704
    AddReturn( $item->barcode, $item->homebranch );
1705
1706
    C4::HoldsQueue::CreateQueue();
1707
1708
    my $sth = $dbh->prepare("SELECT count(*) FROM tmp_holdsqueue");
1709
    $sth->execute();
1710
    my ($count_1) = $sth->fetchrow_array;
1711
1712
    is( $count_1, 1, "Holds queue has one element" );
1713
1714
    AddReturn( $item->barcode, $item->homebranch, undef, dt_from_string );
1715
1716
    ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0,
1717
        $hold->reserve_id );
1718
1719
    $sth->execute();
1720
    my ($count_2) = $sth->fetchrow_array;
1721
1722
    is( $count_2, 0,
1723
        "Holds queue has no elements, even when queue was not rebuilt" );
1724
1725
    $schema->storage->txn_rollback;
1726
};

Return to bug 24359