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 => 68; |
21 |
use Test::More tests => 69; |
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 2090-2095
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
2090 |
is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); |
2090 |
is( Koha::Account::Lines->search({ issue_id => $issue->id })->count, 1, 'UpdateFine should not create a new accountline when updating an existing fine'); |
2091 |
} |
2091 |
} |
2092 |
|
2092 |
|
|
|
2093 |
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub { |
2094 |
plan tests => 3; |
2095 |
|
2096 |
$dbh->do('DELETE FROM issues'); |
2097 |
$dbh->do('DELETE FROM items'); |
2098 |
$dbh->do('DELETE FROM circulation_rules'); |
2099 |
Koha::CirculationRules->set_rules( |
2100 |
{ |
2101 |
categorycode => undef, |
2102 |
itemtype => undef, |
2103 |
branchcode => undef, |
2104 |
rules => { |
2105 |
reservesallowed => 25, |
2106 |
issuelength => 14, |
2107 |
lengthunit => 'days', |
2108 |
renewalsallowed => 1, |
2109 |
renewalperiod => 7, |
2110 |
norenewalbefore => undef, |
2111 |
auto_renew => 0, |
2112 |
fine => .10, |
2113 |
chargeperiod => 1, |
2114 |
maxissueqty => 20, |
2115 |
onshelfholds => 1, |
2116 |
} |
2117 |
} |
2118 |
); |
2119 |
my $biblio = $builder->build_sample_biblio(); |
2120 |
|
2121 |
my $item_1 = $builder->build_sample_item( |
2122 |
{ |
2123 |
biblionumber => $biblio->biblionumber, |
2124 |
library => $library2->{branchcode}, |
2125 |
itype => $itemtype, |
2126 |
} |
2127 |
); |
2128 |
|
2129 |
# add second item with different branchcode |
2130 |
my $item_2 = $builder->build_sample_item( |
2131 |
{ |
2132 |
biblionumber => $biblio->biblionumber, |
2133 |
library => $library->{branchcode}, |
2134 |
itype => $itemtype, |
2135 |
} |
2136 |
); |
2137 |
|
2138 |
my $borrower1 = Koha::Patron->new( |
2139 |
{ |
2140 |
firstname => 'Kyle', |
2141 |
surname => 'Hall', |
2142 |
categorycode => $patron_category->{categorycode}, |
2143 |
branchcode => $library2->{branchcode}, |
2144 |
} |
2145 |
)->store; |
2146 |
my $borrowernumber1 = $borrower1->id; |
2147 |
my $borrower2 = Koha::Patron->new( |
2148 |
{ |
2149 |
firstname => 'Chelsea', |
2150 |
surname => 'Hall', |
2151 |
categorycode => $patron_category->{categorycode}, |
2152 |
branchcode => $library2->{branchcode}, |
2153 |
} |
2154 |
)->store; |
2155 |
my $borrowernumber2 = $borrower2->id; |
2156 |
|
2157 |
my $issue = AddIssue( $borrower1, $item_1->barcode ); |
2158 |
|
2159 |
# place bib-level reserve |
2160 |
AddReserve( |
2161 |
{ |
2162 |
branchcode => $library2->{branchcode}, |
2163 |
borrowernumber => $borrowernumber2, |
2164 |
biblionumber => $biblio->biblionumber, |
2165 |
priority => 1, |
2166 |
} |
2167 |
); |
2168 |
|
2169 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
2170 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' ); |
2171 |
my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
2172 |
is( $renewokay, 1, 'Renewal allowed if items available at any branch' ); |
2173 |
|
2174 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' ); |
2175 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
2176 |
is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' ); |
2177 |
|
2178 |
# adjust 2nd item to have same branchcode |
2179 |
$item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store; |
2180 |
( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue ); |
2181 |
is( $renewokay, 1, 'Renewal allowed if items available at hold branch' ); |
2182 |
}; |
2183 |
|
2093 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
2184 |
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { |
2094 |
plan tests => 24; |
2185 |
plan tests => 24; |
2095 |
|
2186 |
|
2096 |
- |
|
|