Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 4; |
22 |
use Test::More tests => 5; |
23 |
|
23 |
|
24 |
use C4::Biblio; |
24 |
use C4::Biblio; |
25 |
|
25 |
|
Lines 329-331
subtest 'pickup_locations' => sub {
Link Here
|
329 |
|
329 |
|
330 |
$schema->storage->txn_rollback; |
330 |
$schema->storage->txn_rollback; |
331 |
}; |
331 |
}; |
332 |
- |
332 |
|
|
|
333 |
subtest 'renewalbranch' => sub { |
334 |
plan tests => 15; |
335 |
|
336 |
$schema->storage->txn_begin; |
337 |
|
338 |
my $item = $builder->build_sample_item(); |
339 |
my $branch = $builder->build_object({ class => 'Koha::Libraries' }); |
340 |
my $checkout = $builder->build_object({ |
341 |
class => 'Koha::Checkouts', |
342 |
value => { |
343 |
itemnumber => $item->itemnumber, |
344 |
} |
345 |
}); |
346 |
|
347 |
|
348 |
C4::Context->interface( 'intranet' ); |
349 |
t::lib::Mocks::mock_userenv({ branchcode => $branch->branchcode }); |
350 |
|
351 |
is( $item->renewalbranch, $branch->branchcode, "If interface not opac, we get the branch from context"); |
352 |
is( $item->renewalbranch({ branch => "PANDA"}), $branch->branchcode, "If interface not opac, we get the branch from context even if we pass one in"); |
353 |
C4::Context->set_userenv(51, 'userid4tests', undef, 'firstname', 'surname', undef, undef, 0, undef, undef, undef ); #mock userenv doesn't let us set null branch |
354 |
is( $item->renewalbranch({ branch => "PANDA"}), "PANDA", "If interface not opac, we get the branch we pass one in if context not set"); |
355 |
|
356 |
C4::Context->interface( 'opac' ); |
357 |
|
358 |
t::lib::Mocks::mock_preference('OpacRenewalBranch', ''); |
359 |
is( $item->renewalbranch, 'OPACRenew', "If interface opac and OpacRenewalBranch blank, we get the OPACRenew"); |
360 |
is( $item->renewalbranch({branch=>'CHICKEN'}), 'OPACRenew', "If interface opac and OpacRenewalBranch blank, we get the OPACRenew even if branch passes"); |
361 |
|
362 |
t::lib::Mocks::mock_preference('OpacRenewalBranch', undef); |
363 |
is( $item->renewalbranch, 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew"); |
364 |
is( $item->renewalbranch({branch=>'COW'}), 'OPACRenew', "If interface opac and OpacRenewalBranch undef, we get OPACRenew even if branch passed"); |
365 |
|
366 |
t::lib::Mocks::mock_preference('OpacRenewalBranch', 'NULL'); |
367 |
is( $item->renewalbranch, '', "If interface opac and OpacRenewalBranch is string 'NULL', we get blank string"); |
368 |
is( $item->renewalbranch({branch=>'COW'}), '', "If interface opac and OpacRenewalBranch is string 'NULL', we get blank string even if branch passed"); |
369 |
|
370 |
t::lib::Mocks::mock_preference('OpacRenewalBranch', 'checkoutbranch'); |
371 |
is( $item->renewalbranch, $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout"); |
372 |
is( $item->renewalbranch({branch=>'MONKEY'}), $checkout->branchcode, "If interface opac and OpacRenewalBranch set to checkoutbranch, we get branch of checkout even if branch passed"); |
373 |
|
374 |
t::lib::Mocks::mock_preference('OpacRenewalBranch','patronhomebranch'); |
375 |
is( $item->renewalbranch, $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron"); |
376 |
is( $item->renewalbranch({branch=>'TURKEY'}), $checkout->patron->branchcode, "If interface opac and OpacRenewalBranch set to patronbranch, we get branch of patron even if branch passed"); |
377 |
|
378 |
t::lib::Mocks::mock_preference('OpacRenewalBranch','itemhomebranch'); |
379 |
is( $item->renewalbranch, $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item"); |
380 |
is( $item->renewalbranch({branch=>'MANATEE'}), $item->homebranch, "If interface opac and OpacRenewalBranch set to itemhomebranch, we get homebranch of item even if branch passed"); |
381 |
|
382 |
}; |