|
Lines 8-14
Link Here
|
| 8 |
|
8 |
|
| 9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
| 10 |
|
10 |
|
| 11 |
use Test::More tests => 56; |
11 |
use Test::More tests => 57; |
| 12 |
use Data::Dumper; |
12 |
use Data::Dumper; |
| 13 |
|
13 |
|
| 14 |
use C4::Calendar; |
14 |
use C4::Calendar; |
|
Lines 1524-1531
sub test_queue {
Link Here
|
| 1524 |
} |
1524 |
} |
| 1525 |
|
1525 |
|
| 1526 |
subtest "Test _checkHoldPolicy" => sub { |
1526 |
subtest "Test _checkHoldPolicy" => sub { |
|
|
1527 |
|
| 1527 |
plan tests => 25; |
1528 |
plan tests => 25; |
| 1528 |
|
1529 |
|
|
|
1530 |
$schema->storage->txn_begin; |
| 1531 |
|
| 1529 |
my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1532 |
my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1530 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1533 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1531 |
my $library_nongroup = $builder->build_object( { class => 'Koha::Libraries' } ); |
1534 |
my $library_nongroup = $builder->build_object( { class => 'Koha::Libraries' } ); |
|
Lines 1652-1657
subtest "Test _checkHoldPolicy" => sub {
Link Here
|
| 1652 |
$item->{borrowerbranch} = $library2->id; |
1655 |
$item->{borrowerbranch} = $library2->id; |
| 1653 |
is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if library is part of hold group with hfp = holdgroup" ); |
1656 |
is( C4::HoldsQueue::_checkHoldPolicy( $item, $request ), 1, "_checkHoldPolicy returns true if library is part of hold group with hfp = holdgroup" ); |
| 1654 |
$item->{borrowerbranch} = $library1->id; |
1657 |
$item->{borrowerbranch} = $library1->id; |
|
|
1658 |
|
| 1659 |
$schema->storage->txn_rollback; |
| 1655 |
}; |
1660 |
}; |
| 1656 |
|
1661 |
|
| 1657 |
sub dump_records { |
1662 |
sub dump_records { |
|
Lines 1660-1672
sub dump_records {
Link Here
|
| 1660 |
} |
1665 |
} |
| 1661 |
|
1666 |
|
| 1662 |
subtest 'Remove holds on check-in match' => sub { |
1667 |
subtest 'Remove holds on check-in match' => sub { |
|
|
1668 |
|
| 1663 |
plan tests => 2; |
1669 |
plan tests => 2; |
| 1664 |
|
1670 |
|
| 1665 |
$schema->storage->txn_begin; |
1671 |
$schema->storage->txn_begin; |
| 1666 |
|
1672 |
|
| 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' } ); |
1673 |
my $lib = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1671 |
|
1674 |
|
| 1672 |
my $patron1 = $builder->build_object( |
1675 |
my $patron1 = $builder->build_object( |
|
Lines 1705-1712
subtest 'Remove holds on check-in match' => sub {
Link Here
|
| 1705 |
|
1708 |
|
| 1706 |
C4::HoldsQueue::CreateQueue(); |
1709 |
C4::HoldsQueue::CreateQueue(); |
| 1707 |
|
1710 |
|
| 1708 |
my $sth = $dbh->prepare("SELECT count(*) FROM tmp_holdsqueue"); |
1711 |
my $sth = $dbh->prepare(q{ |
| 1709 |
$sth->execute(); |
1712 |
SELECT COUNT(*) |
|
|
1713 |
FROM tmp_holdsqueue q |
| 1714 |
INNER JOIN hold_fill_targets t |
| 1715 |
ON q.borrowernumber = t.borrowernumber |
| 1716 |
AND q.biblionumber = t.biblionumber |
| 1717 |
AND q.itemnumber = t.itemnumber |
| 1718 |
AND q.item_level_request = t.item_level_request |
| 1719 |
AND q.holdingbranch = t.source_branchcode |
| 1720 |
WHERE t.reserve_id = ? |
| 1721 |
}); |
| 1722 |
$sth->execute($hold->reserve_id); |
| 1710 |
my ($count_1) = $sth->fetchrow_array; |
1723 |
my ($count_1) = $sth->fetchrow_array; |
| 1711 |
|
1724 |
|
| 1712 |
is( $count_1, 1, "Holds queue has one element" ); |
1725 |
is( $count_1, 1, "Holds queue has one element" ); |
|
Lines 1716-1722
subtest 'Remove holds on check-in match' => sub {
Link Here
|
| 1716 |
ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0, |
1729 |
ModReserveAffect( $item->itemnumber, $hold->borrowernumber, 0, |
| 1717 |
$hold->reserve_id ); |
1730 |
$hold->reserve_id ); |
| 1718 |
|
1731 |
|
| 1719 |
$sth->execute(); |
1732 |
$sth->execute($hold->reserve_id); |
| 1720 |
my ($count_2) = $sth->fetchrow_array; |
1733 |
my ($count_2) = $sth->fetchrow_array; |
| 1721 |
|
1734 |
|
| 1722 |
is( $count_2, 0, |
1735 |
is( $count_2, 0, |
| 1723 |
- |
|
|