Lines 8-14
Link Here
|
8 |
|
8 |
|
9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
10 |
|
10 |
|
11 |
use Test::More tests => 57; |
11 |
use Test::More tests => 58; |
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 163-169
$dbh->do("DELETE FROM items WHERE holdingbranch = '$borrower_branchcode'");
Link Here
|
163 |
# Frst branch from StaticHoldsQueueWeight |
163 |
# Frst branch from StaticHoldsQueueWeight |
164 |
test_queue ('take from lowest cost branch', 0, $borrower_branchcode, $other_branches[0]); |
164 |
test_queue ('take from lowest cost branch', 0, $borrower_branchcode, $other_branches[0]); |
165 |
test_queue ('take from lowest cost branch', 1, $borrower_branchcode, $least_cost_branch_code); |
165 |
test_queue ('take from lowest cost branch', 1, $borrower_branchcode, $least_cost_branch_code); |
166 |
my $queue = C4::HoldsQueue::GetHoldsQueueItems($least_cost_branch_code) || []; |
166 |
my $queue = C4::HoldsQueue::GetHoldsQueueItems({ branchlmit => $least_cost_branch_code}) || []; |
167 |
my $queue_item = $queue->[0]; |
167 |
my $queue_item = $queue->[0]; |
168 |
ok( $queue_item |
168 |
ok( $queue_item |
169 |
&& $queue_item->{pickbranch} eq $borrower_branchcode |
169 |
&& $queue_item->{pickbranch} eq $borrower_branchcode |
Lines 1737-1739
subtest 'Remove holds on check-in match' => sub {
Link Here
|
1737 |
|
1737 |
|
1738 |
$schema->storage->txn_rollback; |
1738 |
$schema->storage->txn_rollback; |
1739 |
}; |
1739 |
}; |
1740 |
- |
1740 |
|
|
|
1741 |
subtest "GetHoldsQueueItems" => sub { |
1742 |
plan tests => 4; |
1743 |
|
1744 |
$schema->storage->txn_begin; |
1745 |
|
1746 |
my $ccode = $builder->build_object( |
1747 |
{ |
1748 |
class => 'Koha::AuthorisedValues', |
1749 |
value => { |
1750 |
category => 'CCODE' |
1751 |
} |
1752 |
} |
1753 |
); |
1754 |
my $location = $builder->build_object( |
1755 |
{ |
1756 |
class => 'Koha::AuthorisedValues', |
1757 |
value => { |
1758 |
category => 'LOC' |
1759 |
} |
1760 |
} |
1761 |
); |
1762 |
my $item_1 = $builder->build_sample_item(); |
1763 |
my $item_2 = $builder->build_sample_item( |
1764 |
{ |
1765 |
itype => $item_1->itype, |
1766 |
ccode => $ccode->authorised_value |
1767 |
} |
1768 |
); |
1769 |
my $item_3 = $builder->build_sample_item( |
1770 |
{ |
1771 |
itype => $item_1->itype, |
1772 |
ccode => $item_2->ccode, |
1773 |
location => $location->authorised_value |
1774 |
} |
1775 |
); |
1776 |
|
1777 |
my $itemnumber_1 = $item_1->itemnumber; |
1778 |
my $itemnumber_2 = $item_2->itemnumber; |
1779 |
my $itemnumber_3 = $item_3->itemnumber; |
1780 |
|
1781 |
my $biblionumber_1 = $item_1->biblionumber; |
1782 |
my $biblionumber_2 = $item_2->biblionumber; |
1783 |
my $biblionumber_3 = $item_3->biblionumber; |
1784 |
|
1785 |
my $sth = $dbh->prepare(q{ SELECT COUNT(*) FROM tmp_holdsqueue }); |
1786 |
$sth->execute(); |
1787 |
my ($count) = $sth->fetchrow_array; |
1788 |
|
1789 |
$dbh->do( " |
1790 |
INSERT INTO tmp_holdsqueue (itemnumber,biblionumber,surname,firstname,phone,borrowernumber,title,notes) VALUES |
1791 |
($itemnumber_1,$biblionumber_1,'','','',22,'',''), |
1792 |
($itemnumber_2,$biblionumber_2,'','','',32,'',''), |
1793 |
($itemnumber_3,$biblionumber_3,'','','',42,'','') |
1794 |
" ); |
1795 |
|
1796 |
my $queue_items = GetHoldsQueueItems(); |
1797 |
is( scalar @$queue_items, $count + 3, 'Three items added to queue' ); |
1798 |
|
1799 |
$queue_items = GetHoldsQueueItems( { itemtypeslimit => $item_1->itype } ); |
1800 |
is( scalar @$queue_items, |
1801 |
3, 'Three items of same itemtype found when itemtypeslimit passed' ); |
1802 |
|
1803 |
$queue_items = GetHoldsQueueItems( |
1804 |
{ itemtypeslimit => $item_1->itype, ccodeslimit => $item_2->ccode } ); |
1805 |
is( scalar @$queue_items, |
1806 |
2, 'Two items of same collection found when ccodeslimit passed' ); |
1807 |
|
1808 |
@$queue_items = GetHoldsQueueItems( |
1809 |
{ |
1810 |
itemtypeslimit => $item_1->itype, |
1811 |
ccodeslimit => $item_2->ccode, |
1812 |
locationslimit => $item_3->location |
1813 |
} |
1814 |
); |
1815 |
is( scalar @$queue_items, |
1816 |
1, 'One item of shleving location found when locationslimit passed' ); |
1817 |
|
1818 |
$schema->storage->txn_rollback; |
1819 |
}; |