Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 52; |
21 |
use Test::More tests => 53; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
Lines 1818-1823
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1818 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1818 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1819 |
}; |
1819 |
}; |
1820 |
|
1820 |
|
|
|
1821 |
|
1822 |
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { |
1823 |
plan tests => 6; |
1824 |
|
1825 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
1826 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
1827 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1828 |
|
1829 |
my $item = $builder->build_sample_item( |
1830 |
{ |
1831 |
homebranch => $homebranch->{branchcode}, |
1832 |
holdingbranch => $homebranch->{branchcode}, |
1833 |
} |
1834 |
); |
1835 |
|
1836 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1837 |
set_userenv($homebranch); |
1838 |
my $issue = AddIssue( $patron, $item->barcode ); |
1839 |
my ($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $otherbranch); |
1840 |
is ( 1 , $allowed , 'with AllowReturnToBranch = anywhere and no limits return to other is allowed'); |
1841 |
is ( undef , $message , 'without limits provides no message'); |
1842 |
|
1843 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); |
1844 |
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); |
1845 |
|
1846 |
# set limit |
1847 |
my $limit = Koha::Item::Transfer::Limit->new({ |
1848 |
toBranch => $otherbranch->{branchcode}, |
1849 |
fromBranch => $item->homebranch, |
1850 |
itemtype => $item->effective_itemtype, |
1851 |
})->store(); |
1852 |
|
1853 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $otherbranch); |
1854 |
is ( 0 , $allowed , 'With transfer limits cannot return to otherbranch'); |
1855 |
is ( $homebranch->{branchcode} , $message , 'With transfer limits asks return to homebranch'); |
1856 |
|
1857 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $homebranch); |
1858 |
is ( 1 , $allowed , 'With transfer limits can return to homebranch'); |
1859 |
is ( undef , $message , 'With transfer limits and homebranch provides no message'); |
1860 |
}; |
1861 |
|
1821 |
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { |
1862 |
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { |
1822 |
plan tests => 8; |
1863 |
plan tests => 8; |
1823 |
|
1864 |
|
1824 |
- |
|
|