Lines 8-14
Link Here
|
8 |
|
8 |
|
9 |
use Modern::Perl; |
9 |
use Modern::Perl; |
10 |
|
10 |
|
11 |
use Test::More tests => 58; |
11 |
use Test::More tests => 59; |
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 1817-1819
subtest "GetHoldsQueueItems" => sub {
Link Here
|
1817 |
|
1817 |
|
1818 |
$schema->storage->txn_rollback; |
1818 |
$schema->storage->txn_rollback; |
1819 |
}; |
1819 |
}; |
1820 |
- |
1820 |
|
|
|
1821 |
subtest "Test HoldsQueuePrioritizeBranch" => sub { |
1822 |
plan tests => 4; |
1823 |
|
1824 |
Koha::Biblios->delete(); |
1825 |
t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); |
1826 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'homebranch' ); |
1827 |
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 0); |
1828 |
|
1829 |
my $branch1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1830 |
my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
1831 |
my $category = $builder->build_object( { class => 'Koha::Patron::Categories' }); |
1832 |
my $patron = $builder->build_object( |
1833 |
{ |
1834 |
class => "Koha::Patrons", |
1835 |
value => { |
1836 |
branchcode => $branch1->branchcode, |
1837 |
categorycode => $category->categorycode |
1838 |
} |
1839 |
} |
1840 |
); |
1841 |
|
1842 |
my $biblio = $builder->build_sample_biblio(); |
1843 |
my $item1 = $builder->build_sample_item( |
1844 |
{ |
1845 |
biblionumber => $biblio->biblionumber, |
1846 |
library => $branch1->branchcode, |
1847 |
} |
1848 |
)->holdingbranch( $branch2->id )->store(); |
1849 |
|
1850 |
my $item2 = $builder->build_sample_item( |
1851 |
{ |
1852 |
biblionumber => $biblio->biblionumber, |
1853 |
library => $branch1->branchcode, |
1854 |
} |
1855 |
)->homebranch( $branch2->id )->store(); |
1856 |
|
1857 |
my $reserve_id = AddReserve( |
1858 |
{ |
1859 |
branchcode => $branch1->branchcode, |
1860 |
borrowernumber => $patron->borrowernumber, |
1861 |
biblionumber => $biblio->biblionumber, |
1862 |
priority => 1, |
1863 |
} |
1864 |
); |
1865 |
|
1866 |
C4::HoldsQueue::CreateQueue(); |
1867 |
|
1868 |
my $queue_rs = $schema->resultset('TmpHoldsqueue'); |
1869 |
my $target_rs = $schema->resultset('HoldFillTarget'); |
1870 |
is( |
1871 |
$queue_rs->next->itemnumber->itemnumber, |
1872 |
$item1->itemnumber, |
1873 |
"Picked the item whose homebranch matches the pickup branch" |
1874 |
); |
1875 |
|
1876 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'holdingbranch' ); |
1877 |
|
1878 |
C4::HoldsQueue::CreateQueue(); |
1879 |
|
1880 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
1881 |
$target_rs = $schema->resultset('HoldFillTarget'); |
1882 |
is( |
1883 |
$queue_rs->next->itemnumber->itemnumber, |
1884 |
$item2->itemnumber, |
1885 |
"Picked the item whose holdingbranch matches the pickup branch" |
1886 |
); |
1887 |
|
1888 |
t::lib::Mocks::mock_preference('UseTransportCostMatrix', 1); |
1889 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'homebranch' ); |
1890 |
|
1891 |
C4::HoldsQueue::CreateQueue(); |
1892 |
|
1893 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
1894 |
$target_rs = $schema->resultset('HoldFillTarget'); |
1895 |
is( |
1896 |
$queue_rs->next->itemnumber->itemnumber, |
1897 |
$item1->itemnumber, |
1898 |
"Picked the item whose homebranch matches the pickup branch" |
1899 |
); |
1900 |
|
1901 |
t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'holdingbranch' ); |
1902 |
|
1903 |
C4::HoldsQueue::CreateQueue(); |
1904 |
|
1905 |
$queue_rs = $schema->resultset('TmpHoldsqueue'); |
1906 |
$target_rs = $schema->resultset('HoldFillTarget'); |
1907 |
is( |
1908 |
$queue_rs->next->itemnumber->itemnumber, |
1909 |
$item2->itemnumber, |
1910 |
"Picked the item whose holdingbranch matches the pickup branch" |
1911 |
); |
1912 |
}; |