Lines 26-32
use C4::Reserves;
Link Here
|
26 |
use Koha::DateUtils; |
26 |
use Koha::DateUtils; |
27 |
use Koha::Database; |
27 |
use Koha::Database; |
28 |
|
28 |
|
29 |
use Test::More tests => 57; |
29 |
use Test::More tests => 59; |
30 |
|
30 |
|
31 |
BEGIN { |
31 |
BEGIN { |
32 |
use_ok('C4::Circulation'); |
32 |
use_ok('C4::Circulation'); |
Lines 233-239
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
233 |
$biblionumber |
233 |
$biblionumber |
234 |
); |
234 |
); |
235 |
|
235 |
|
236 |
# Create 2 borrowers |
236 |
# Create borrowers |
237 |
my %renewing_borrower_data = ( |
237 |
my %renewing_borrower_data = ( |
238 |
firstname => 'John', |
238 |
firstname => 'John', |
239 |
surname => 'Renewal', |
239 |
surname => 'Renewal', |
Lines 248-255
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
248 |
branchcode => $branch, |
248 |
branchcode => $branch, |
249 |
); |
249 |
); |
250 |
|
250 |
|
|
|
251 |
my %hold_waiting_borrower_data = ( |
252 |
firstname => 'Kyle', |
253 |
surname => 'Reservation', |
254 |
categorycode => 'S', |
255 |
branchcode => $branch, |
256 |
); |
257 |
|
251 |
my $renewing_borrowernumber = AddMember(%renewing_borrower_data); |
258 |
my $renewing_borrowernumber = AddMember(%renewing_borrower_data); |
252 |
my $reserving_borrowernumber = AddMember(%reserving_borrower_data); |
259 |
my $reserving_borrowernumber = AddMember(%reserving_borrower_data); |
|
|
260 |
my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data); |
253 |
|
261 |
|
254 |
my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber ); |
262 |
my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber ); |
255 |
|
263 |
|
Lines 282-292
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
282 |
$title, $checkitem, $found |
290 |
$title, $checkitem, $found |
283 |
); |
291 |
); |
284 |
|
292 |
|
|
|
293 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
285 |
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
294 |
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
286 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
295 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
287 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
296 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
288 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
297 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
289 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
298 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
|
|
299 |
# Now let's add a waiting hold on the 3rd item, it's no longer available tp check out by just anyone, so we should no longer |
300 |
# be able to renew these items |
301 |
my $hold = Koha::Database->new()->schema()->resultset('Reserve')->create( |
302 |
{ |
303 |
borrowernumber => $hold_waiting_borrowernumber, |
304 |
biblionumber => $biblionumber, |
305 |
itemnumber => $itemnumber3, |
306 |
branchcode => $branch, |
307 |
priority => 0, |
308 |
found => 'W' |
309 |
} |
310 |
); |
311 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
312 |
is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
313 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
314 |
is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
290 |
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 0 ); |
315 |
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 0 ); |
291 |
|
316 |
|
292 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
317 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
293 |
- |
|
|