Lines 19-25
use Modern::Perl;
Link Here
|
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
22 |
use Test::More tests => 77; |
22 |
use Test::More tests => 78; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
25 |
use Test::Deep qw( cmp_deeply ); |
25 |
use Test::Deep qw( cmp_deeply ); |
Lines 2957-2962
subtest 'CanBookBeReturned + UseBranchTransfertLimits + CirculationRules' => sub
Link Here
|
2957 |
is( $holdingbranch->{branchcode}, $message, 'Redirect to holdingbranch' ); |
2957 |
is( $holdingbranch->{branchcode}, $message, 'Redirect to holdingbranch' ); |
2958 |
}; |
2958 |
}; |
2959 |
|
2959 |
|
|
|
2960 |
subtest 'AddReturn + TransferLimits' => sub { |
2961 |
plan tests => 3; |
2962 |
|
2963 |
######################################################################## |
2964 |
# |
2965 |
# Prepare test |
2966 |
# |
2967 |
######################################################################## |
2968 |
|
2969 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2970 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2971 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
2972 |
my $returnbranch = $builder->build( { source => 'Branch' } ); |
2973 |
my $item = $builder->build_sample_item( |
2974 |
{ |
2975 |
homebranch => $homebranch->{branchcode}, |
2976 |
holdingbranch => $holdingbranch->{branchcode}, |
2977 |
} |
2978 |
); |
2979 |
|
2980 |
# Default circulation rules |
2981 |
Koha::CirculationRules->set_rules( |
2982 |
{ |
2983 |
categorycode => undef, |
2984 |
branchcode => undef, |
2985 |
itemtype => $item->itype, |
2986 |
rules => { |
2987 |
maxissueqty => 1, |
2988 |
reservesallowed => 25, |
2989 |
issuelength => 7, |
2990 |
lengthunit => 'days', |
2991 |
renewalsallowed => 5, |
2992 |
renewalperiod => 7, |
2993 |
norenewalbefore => undef, |
2994 |
auto_renew => 0, |
2995 |
fine => .10, |
2996 |
chargeperiod => 1, |
2997 |
} |
2998 |
} |
2999 |
); |
3000 |
t::lib::Mocks::mock_userenv( { branchcode => $holdingbranch->{branchcode} } ); |
3001 |
|
3002 |
# Each transfer from returnbranch is forbidden |
3003 |
my $limit = Koha::Item::Transfer::Limit->new( |
3004 |
{ |
3005 |
fromBranch => $returnbranch->{branchcode}, |
3006 |
toBranch => $holdingbranch->{branchcode}, |
3007 |
itemtype => $item->effective_itemtype, |
3008 |
} |
3009 |
)->store(); |
3010 |
my $limit2 = Koha::Item::Transfer::Limit->new( |
3011 |
{ |
3012 |
fromBranch => $returnbranch->{branchcode}, |
3013 |
toBranch => $homebranch->{branchcode}, |
3014 |
itemtype => $item->effective_itemtype, |
3015 |
} |
3016 |
)->store(); |
3017 |
|
3018 |
######################################################################## |
3019 |
# |
3020 |
# Begin test |
3021 |
# |
3022 |
# Each transfer is forbidden by transfer limits |
3023 |
# Checkin must be forbidden except if there is no transfer to perform |
3024 |
# |
3025 |
######################################################################## |
3026 |
|
3027 |
# Case 1: There is a transfer to to do homebranch |
3028 |
Koha::CirculationRules->set_rules( |
3029 |
{ |
3030 |
branchcode => undef, |
3031 |
itemtype => undef, |
3032 |
rules => { |
3033 |
returnbranch => 'homebranch', |
3034 |
}, |
3035 |
} |
3036 |
); |
3037 |
my $issue = AddIssue( $patron, $item->barcode ); |
3038 |
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item->barcode, $returnbranch->{branchcode} ); |
3039 |
is( $doreturn, 0, "Item cannot be returned if there is a transfer to do" ); |
3040 |
|
3041 |
# Case 2: There is a transfer to do to holdingbranch |
3042 |
Koha::CirculationRules->set_rules( |
3043 |
{ |
3044 |
branchcode => undef, |
3045 |
itemtype => undef, |
3046 |
rules => { |
3047 |
returnbranch => 'holdingbranch', |
3048 |
}, |
3049 |
} |
3050 |
); |
3051 |
$issue->delete; |
3052 |
$item->holdingbranch( $holdingbranch->{branchcode} )->store(); |
3053 |
$issue = AddIssue( $patron, $item->barcode ); |
3054 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item->barcode, $returnbranch->{branchcode} ); |
3055 |
is( $doreturn, 0, "Item cannot be returned if there is a transfer to do (item is floating)" ); |
3056 |
|
3057 |
# Case 3: There is no transfer to do |
3058 |
Koha::CirculationRules->set_rules( |
3059 |
{ |
3060 |
branchcode => undef, |
3061 |
itemtype => undef, |
3062 |
rules => { |
3063 |
returnbranch => 'noreturn', |
3064 |
}, |
3065 |
} |
3066 |
); |
3067 |
$issue->delete; |
3068 |
$issue = AddIssue( $patron, $item->barcode ); |
3069 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item->barcode, $returnbranch->{branchcode} ); |
3070 |
is( $doreturn, 1, "Item cannot be returned if there is a transfer to do" ); |
3071 |
}; |
3072 |
|
2960 |
subtest 'Statistic patrons "X"' => sub { |
3073 |
subtest 'Statistic patrons "X"' => sub { |
2961 |
plan tests => 15; |
3074 |
plan tests => 15; |
2962 |
|
3075 |
|
Lines 3044-3051
subtest 'Statistic patrons "X"' => sub {
Link Here
|
3044 |
Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 3, |
3157 |
Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 3, |
3045 |
'Issue, return, and localuse should be recorded in statistics table for item 4.' |
3158 |
'Issue, return, and localuse should be recorded in statistics table for item 4.' |
3046 |
); |
3159 |
); |
3047 |
|
|
|
3048 |
# TODO There are other tests to provide here |
3049 |
}; |
3160 |
}; |
3050 |
|
3161 |
|
3051 |
subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub { |
3162 |
subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub { |
3052 |
- |
|
|