Lines 23-32
use DateTime::Duration;
Link Here
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
|
25 |
|
26 |
use C4::Circulation; |
|
|
27 |
use C4::Items; |
28 |
use C4::Biblio; |
26 |
use C4::Biblio; |
|
|
27 |
use C4::Circulation; |
29 |
use C4::Context; |
28 |
use C4::Context; |
|
|
29 |
use C4::Items; |
30 |
use C4::Reserves; |
30 |
use C4::Reserves; |
31 |
use Koha::Checkouts; |
31 |
use Koha::Checkouts; |
32 |
use Koha::Database; |
32 |
use Koha::Database; |
Lines 243-267
like(
Link Here
|
243 |
my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 ); |
243 |
my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 ); |
244 |
ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" ); |
244 |
ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" ); |
245 |
|
245 |
|
246 |
$se->mock( 'interface', sub {return 'opac'}); |
246 |
subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub { |
247 |
|
247 |
plan tests => 5; |
248 |
#Let's do an opac renewal - whatever branchcode we send should be used |
248 |
|
249 |
my $opac_renew_issue = $builder->build({ |
249 |
$se->mock( 'interface', sub { return 'opac' } ); |
250 |
source=>"Issue", |
250 |
|
251 |
value=>{ |
251 |
t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'OPACRenew' ); |
252 |
date_due => '2017-01-01', |
252 |
my $opac_renew_issue = $builder->build( |
253 |
branch => $branchcode_1, |
253 |
{ |
254 |
itype => $itemtype, |
254 |
source => "Issue", |
255 |
borrowernumber => $borrower_id1 |
255 |
value => { |
256 |
} |
256 |
date_due => '2017-01-01', |
257 |
}); |
257 |
returndate => undef, |
258 |
|
258 |
branch => $branchcode_1, |
259 |
my $datedue4 = AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, "Stavromula", $datedue1, $daysago10 ); |
259 |
itype => $itemtype, |
260 |
|
260 |
borrowernumber => $borrower_id1 |
261 |
$stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, "Stavromula" ); |
261 |
} |
262 |
ok( $stat, "Bug 18572 - 'Bug 18572 - OpacRenewalBranch is now respected" ); |
262 |
} |
263 |
|
263 |
); |
264 |
|
264 |
AddRenewal( |
|
|
265 |
$opac_renew_issue->{borrowernumber}, |
266 |
$opac_renew_issue->{itemnumber}, |
267 |
"Stavromula", $datedue1, $daysago10 |
268 |
); |
269 |
my $stat = $schema->resultset('Statistic')->search({ itemnumber => $opac_renew_issue->{itemnumber}})->next; |
270 |
is( $stat->branch, "OPACRenew", "OpacRenewalBranch is respected for OpacRenewalBranch = OPACRenew" ); |
271 |
|
272 |
t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'checkoutbranch' ); |
273 |
$opac_renew_issue = $builder->build( |
274 |
{ |
275 |
source => "Issue", |
276 |
value => { |
277 |
date_due => '2017-01-01', |
278 |
returndate => undef, |
279 |
branch => $branchcode_1, |
280 |
itype => $itemtype, |
281 |
borrowernumber => $borrower_id1 |
282 |
} |
283 |
} |
284 |
); |
285 |
AddRenewal( |
286 |
$opac_renew_issue->{borrowernumber}, |
287 |
$opac_renew_issue->{itemnumber}, |
288 |
"Stavromula", $datedue1, $daysago10 |
289 |
); |
290 |
$stat = $schema->resultset('Statistic')->search({ itemnumber => $opac_renew_issue->{itemnumber}})->next; |
291 |
is( $stat->branch, $opac_renew_issue->{branchcode}, "OpacRenewalBranch is respected for OpacRenewalBranch = checkoutbranch" ); |
292 |
|
293 |
t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'patronhomebranch' ); |
294 |
$opac_renew_issue = $builder->build( |
295 |
{ |
296 |
source => "Issue", |
297 |
value => { |
298 |
date_due => '2017-01-01', |
299 |
returndate => undef, |
300 |
branch => $branchcode_1, |
301 |
itype => $itemtype, |
302 |
borrowernumber => $borrower_id1 |
303 |
} |
304 |
} |
305 |
); |
306 |
AddRenewal( |
307 |
$opac_renew_issue->{borrowernumber}, |
308 |
$opac_renew_issue->{itemnumber}, |
309 |
"Stavromula", $datedue1, $daysago10 |
310 |
); |
311 |
$stat = $schema->resultset('Statistic')->search({ itemnumber => $opac_renew_issue->{itemnumber}})->next; |
312 |
my $patron = Koha::Patrons->find( $borrower_id1 ); |
313 |
is( $stat->branch, $patron->branchcode, "OpacRenewalBranch is respected for OpacRenewalBranch = patronhomebranch" ); |
314 |
|
315 |
t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'itemhomebranch' ); |
316 |
$opac_renew_issue = $builder->build( |
317 |
{ |
318 |
source => "Issue", |
319 |
value => { |
320 |
date_due => '2017-01-01', |
321 |
returndate => undef, |
322 |
branch => $branchcode_1, |
323 |
itype => $itemtype, |
324 |
borrowernumber => $borrower_id1 |
325 |
} |
326 |
} |
327 |
); |
328 |
AddRenewal( |
329 |
$opac_renew_issue->{borrowernumber}, |
330 |
$opac_renew_issue->{itemnumber}, |
331 |
"Stavromula", $datedue1, $daysago10 |
332 |
); |
333 |
$stat = $schema->resultset('Statistic')->search({ itemnumber => $opac_renew_issue->{itemnumber}})->next; |
334 |
my $item = Koha::Items->find( $opac_renew_issue->{itemnumber} ); |
335 |
is( $stat->branch, $item->homebranch, "OpacRenewalBranch is respected for OpacRenewalBranch = itemhomebranch" ); |
336 |
|
337 |
t::lib::Mocks::mock_preference( 'OpacRenewalBranch', 'NULL' ); |
338 |
$opac_renew_issue = $builder->build( |
339 |
{ |
340 |
source => "Issue", |
341 |
value => { |
342 |
date_due => '2017-01-01', |
343 |
returndate => undef, |
344 |
branch => $branchcode_1, |
345 |
itype => $itemtype, |
346 |
borrowernumber => $borrower_id1 |
347 |
} |
348 |
} |
349 |
); |
350 |
AddRenewal( |
351 |
$opac_renew_issue->{borrowernumber}, |
352 |
$opac_renew_issue->{itemnumber}, |
353 |
"Stavromula", $datedue1, $daysago10 |
354 |
); |
355 |
$stat = $schema->resultset('Statistic')->search({ itemnumber => $opac_renew_issue->{itemnumber}})->next; |
356 |
is( $stat->branch, "", "OpacRenewalBranch is respected for OpacRenewalBranch = NULL" ); |
357 |
}; |
265 |
|
358 |
|
266 |
#Test GetBiblioIssues |
359 |
#Test GetBiblioIssues |
267 |
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); |
360 |
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" ); |
268 |
- |
|
|