Lines 1967-1969
subtest "GetHoldsQueueItems" => sub {
Link Here
|
1967 |
|
1967 |
|
1968 |
$schema->storage->txn_rollback; |
1968 |
$schema->storage->txn_rollback; |
1969 |
}; |
1969 |
}; |
1970 |
- |
1970 |
|
|
|
1971 |
subtest "Test HoldsQueuePrioritizeBranch" => sub { |
1972 |
plan tests => 4; |
1973 |
|
1974 |
Koha::Biblios->delete(); |
1975 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); |
1976 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'homebranch' ); |
1977 |
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0); |
1978 |
|
1979 |
my $branch1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1980 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1981 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories' }); |
1982 |
my $patron = $builder->build_object( |
1983 |
{ |
1984 |
class => "Koha::Patrons", |
1985 |
value => { |
1986 |
branchcode => $branch1->branchcode, |
1987 |
categorycode => $category->categorycode |
1988 |
} |
1989 |
} |
1990 |
); |
1991 |
|
1992 |
my $biblio = $builder->build_sample_biblio(); |
1993 |
my $item1 = $builder->build_sample_item( |
1994 |
{ |
1995 |
biblionumber => $biblio->biblionumber, |
1996 |
library => $branch1->branchcode, |
1997 |
} |
1998 |
)->holdingbranch( $branch2->id )->store(); |
1999 |
|
2000 |
my $item2 = $builder->build_sample_item( |
2001 |
{ |
2002 |
biblionumber => $biblio->biblionumber, |
2003 |
library => $branch1->branchcode, |
2004 |
} |
2005 |
)->homebranch( $branch2->id )->store(); |
2006 |
|
2007 |
my $reserve_id = AddReserve( |
2008 |
{ |
2009 |
branchcode => $branch1->branchcode, |
2010 |
borrowernumber => $patron->borrowernumber, |
2011 |
biblionumber => $biblio->biblionumber, |
2012 |
priority => 1, |
2013 |
} |
2014 |
); |
2015 |
|
2016 |
C4::HoldsQueue::CreateQueue(); |
2017 |
|
2018 |
my $queue_rs = $schema->resultset('TmpHoldsqueue'); |
2019 |
my $target_rs = $schema->resultset('HoldFillTarget'); |
2020 |
is( |
2021 |
$queue_rs->next->itemnumber->itemnumber, |
2022 |
$item1->itemnumber, |
2023 |
"Picked the item whose homebranch matches the pickup branch" |
2024 |
); |
2025 |
|
2026 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'holdingbranch' ); |
2027 |
|
2028 |
C4::HoldsQueue::CreateQueue(); |
2029 |
|
2030 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
2031 |
$target_rs = $schema->resultset('HoldFillTarget'); |
2032 |
is( |
2033 |
$queue_rs->next->itemnumber->itemnumber, |
2034 |
$item2->itemnumber, |
2035 |
"Picked the item whose holdingbranch matches the pickup branch" |
2036 |
); |
2037 |
|
2038 |
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 1); |
2039 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'homebranch' ); |
2040 |
|
2041 |
C4::HoldsQueue::CreateQueue(); |
2042 |
|
2043 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
2044 |
$target_rs = $schema->resultset('HoldFillTarget'); |
2045 |
is( |
2046 |
$queue_rs->next->itemnumber->itemnumber, |
2047 |
$item1->itemnumber, |
2048 |
"Picked the item whose homebranch matches the pickup branch" |
2049 |
); |
2050 |
|
2051 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'holdingbranch' ); |
2052 |
|
2053 |
C4::HoldsQueue::CreateQueue(); |
2054 |
|
2055 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
2056 |
$target_rs = $schema->resultset('HoldFillTarget'); |
2057 |
is( |
2058 |
$queue_rs->next->itemnumber->itemnumber, |
2059 |
$item2->itemnumber, |
2060 |
"Picked the item whose holdingbranch matches the pickup branch" |
2061 |
); |
2062 |
}; |