|
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 => 86; |
22 |
use Test::More tests => 87; |
| 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 3012-3017
subtest 'CanBookBeReturned + UseBranchTransfertLimits + CirculationRules' => sub
Link Here
|
| 3012 |
is( $holdingbranch->{branchcode}, $message, 'Redirect to holdingbranch' ); |
3012 |
is( $holdingbranch->{branchcode}, $message, 'Redirect to holdingbranch' ); |
| 3013 |
}; |
3013 |
}; |
| 3014 |
|
3014 |
|
|
|
3015 |
subtest 'AddReturn + TransferLimits' => sub { |
| 3016 |
plan tests => 3; |
| 3017 |
|
| 3018 |
######################################################################## |
| 3019 |
# |
| 3020 |
# Prepare test |
| 3021 |
# |
| 3022 |
######################################################################## |
| 3023 |
|
| 3024 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3025 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
| 3026 |
my $holdingbranch = $builder->build( { source => 'Branch' } ); |
| 3027 |
my $returnbranch = $builder->build( { source => 'Branch' } ); |
| 3028 |
my $item = $builder->build_sample_item( |
| 3029 |
{ |
| 3030 |
homebranch => $homebranch->{branchcode}, |
| 3031 |
holdingbranch => $holdingbranch->{branchcode}, |
| 3032 |
} |
| 3033 |
); |
| 3034 |
|
| 3035 |
# Default circulation rules |
| 3036 |
Koha::CirculationRules->set_rules( |
| 3037 |
{ |
| 3038 |
categorycode => undef, |
| 3039 |
branchcode => undef, |
| 3040 |
itemtype => $item->itype, |
| 3041 |
rules => { |
| 3042 |
maxissueqty => 1, |
| 3043 |
reservesallowed => 25, |
| 3044 |
issuelength => 7, |
| 3045 |
lengthunit => 'days', |
| 3046 |
renewalsallowed => 5, |
| 3047 |
renewalperiod => 7, |
| 3048 |
norenewalbefore => undef, |
| 3049 |
auto_renew => 0, |
| 3050 |
fine => .10, |
| 3051 |
chargeperiod => 1, |
| 3052 |
} |
| 3053 |
} |
| 3054 |
); |
| 3055 |
t::lib::Mocks::mock_userenv( { branchcode => $holdingbranch->{branchcode} } ); |
| 3056 |
|
| 3057 |
# Each transfer from returnbranch is forbidden |
| 3058 |
my $limit = Koha::Item::Transfer::Limit->new( |
| 3059 |
{ |
| 3060 |
fromBranch => $returnbranch->{branchcode}, |
| 3061 |
toBranch => $holdingbranch->{branchcode}, |
| 3062 |
itemtype => $item->effective_itemtype, |
| 3063 |
} |
| 3064 |
)->store(); |
| 3065 |
my $limit2 = Koha::Item::Transfer::Limit->new( |
| 3066 |
{ |
| 3067 |
fromBranch => $returnbranch->{branchcode}, |
| 3068 |
toBranch => $homebranch->{branchcode}, |
| 3069 |
itemtype => $item->effective_itemtype, |
| 3070 |
} |
| 3071 |
)->store(); |
| 3072 |
|
| 3073 |
######################################################################## |
| 3074 |
# |
| 3075 |
# Begin test |
| 3076 |
# |
| 3077 |
# Each transfer is forbidden by transfer limits |
| 3078 |
# Checkin must be forbidden except if there is no transfer to perform |
| 3079 |
# |
| 3080 |
######################################################################## |
| 3081 |
|
| 3082 |
# Case 1: There is a transfer to to do homebranch |
| 3083 |
Koha::CirculationRules->set_rules( |
| 3084 |
{ |
| 3085 |
branchcode => undef, |
| 3086 |
itemtype => undef, |
| 3087 |
rules => { |
| 3088 |
returnbranch => 'homebranch', |
| 3089 |
}, |
| 3090 |
} |
| 3091 |
); |
| 3092 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 3093 |
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item->barcode, $returnbranch->{branchcode} ); |
| 3094 |
is( $doreturn, 0, "Item cannot be returned if there is a transfer to do" ); |
| 3095 |
|
| 3096 |
# Case 2: There is a transfer to do to holdingbranch |
| 3097 |
Koha::CirculationRules->set_rules( |
| 3098 |
{ |
| 3099 |
branchcode => undef, |
| 3100 |
itemtype => undef, |
| 3101 |
rules => { |
| 3102 |
returnbranch => 'holdingbranch', |
| 3103 |
}, |
| 3104 |
} |
| 3105 |
); |
| 3106 |
$issue->delete; |
| 3107 |
$item->holdingbranch( $holdingbranch->{branchcode} )->store(); |
| 3108 |
$issue = AddIssue( $patron, $item->barcode ); |
| 3109 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item->barcode, $returnbranch->{branchcode} ); |
| 3110 |
is( $doreturn, 0, "Item cannot be returned if there is a transfer to do (item is floating)" ); |
| 3111 |
|
| 3112 |
# Case 3: There is no transfer to do |
| 3113 |
Koha::CirculationRules->set_rules( |
| 3114 |
{ |
| 3115 |
branchcode => undef, |
| 3116 |
itemtype => undef, |
| 3117 |
rules => { |
| 3118 |
returnbranch => 'noreturn', |
| 3119 |
}, |
| 3120 |
} |
| 3121 |
); |
| 3122 |
$issue->delete; |
| 3123 |
$issue = AddIssue( $patron, $item->barcode ); |
| 3124 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item->barcode, $returnbranch->{branchcode} ); |
| 3125 |
is( $doreturn, 1, "Item cannot be returned if there is a transfer to do" ); |
| 3126 |
}; |
| 3127 |
|
| 3015 |
subtest 'Statistic patrons "X"' => sub { |
3128 |
subtest 'Statistic patrons "X"' => sub { |
| 3016 |
plan tests => 15; |
3129 |
plan tests => 15; |
| 3017 |
|
3130 |
|
|
Lines 3099-3106
subtest 'Statistic patrons "X"' => sub {
Link Here
|
| 3099 |
Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 3, |
3212 |
Koha::Statistics->search( { itemnumber => $item_4->itemnumber } )->count, 3, |
| 3100 |
'Issue, return, and localuse should be recorded in statistics table for item 4.' |
3213 |
'Issue, return, and localuse should be recorded in statistics table for item 4.' |
| 3101 |
); |
3214 |
); |
| 3102 |
|
|
|
| 3103 |
# TODO There are other tests to provide here |
| 3104 |
}; |
3215 |
}; |
| 3105 |
|
3216 |
|
| 3106 |
subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub { |
3217 |
subtest "Bug 27753 - Add AutoClaimReturnStatusOnCheckin" => sub { |
| 3107 |
- |
|
|