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 => 54; |
21 |
use Test::More tests => 55; |
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 1924-1929
subtest 'AddIssue & AllowReturnToBranch' => sub {
Link Here
|
1924 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1924 |
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); |
1925 |
}; |
1925 |
}; |
1926 |
|
1926 |
|
|
|
1927 |
|
1928 |
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { |
1929 |
plan tests => 6; |
1930 |
|
1931 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
1932 |
my $otherbranch = $builder->build( { source => 'Branch' } ); |
1933 |
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); |
1934 |
|
1935 |
my $item = $builder->build_sample_item( |
1936 |
{ |
1937 |
homebranch => $homebranch->{branchcode}, |
1938 |
holdingbranch => $homebranch->{branchcode}, |
1939 |
} |
1940 |
); |
1941 |
|
1942 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
1943 |
set_userenv($homebranch); |
1944 |
my $issue = AddIssue( $patron, $item->barcode ); |
1945 |
my ($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $otherbranch); |
1946 |
is ( 1 , $allowed , 'with AllowReturnToBranch = anywhere and no limits return to other is allowed'); |
1947 |
is ( undef , $message , 'without limits provides no message'); |
1948 |
|
1949 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); |
1950 |
t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); |
1951 |
|
1952 |
# set limit |
1953 |
my $limit = Koha::Item::Transfer::Limit->new({ |
1954 |
toBranch => $otherbranch->{branchcode}, |
1955 |
fromBranch => $item->homebranch, |
1956 |
itemtype => $item->effective_itemtype, |
1957 |
})->store(); |
1958 |
|
1959 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $otherbranch); |
1960 |
is ( 0 , $allowed , 'With transfer limits cannot return to otherbranch'); |
1961 |
is ( $homebranch->{branchcode} , $message , 'With transfer limits asks return to homebranch'); |
1962 |
|
1963 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $homebranch); |
1964 |
is ( 1 , $allowed , 'With transfer limits can return to homebranch'); |
1965 |
is ( undef , $message , 'With transfer limits and homebranch provides no message'); |
1966 |
}; |
1967 |
|
1927 |
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { |
1968 |
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { |
1928 |
plan tests => 8; |
1969 |
plan tests => 8; |
1929 |
|
1970 |
|
1930 |
- |
|
|