|
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 => 51; |
21 |
use Test::More tests => 52; |
| 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 282-287
Koha::CirculationRules->set_rules(
Link Here
|
| 282 |
} |
282 |
} |
| 283 |
); |
283 |
); |
| 284 |
|
284 |
|
|
|
285 |
subtest "GetIssuingCharges tests" => sub { |
| 286 |
plan tests => 4; |
| 287 |
my $branch_discount = $builder->build_object({ class => 'Koha::Libraries' }); |
| 288 |
my $branch_no_discount = $builder->build_object({ class => 'Koha::Libraries' }); |
| 289 |
Koha::CirculationRules->set_rule( |
| 290 |
{ |
| 291 |
categorycode => undef, |
| 292 |
branchcode => $branch_discount->branchcode, |
| 293 |
itemtype => undef, |
| 294 |
rule_name => 'rentaldiscount', |
| 295 |
rule_value => 15 |
| 296 |
} |
| 297 |
); |
| 298 |
my $itype_charge = $builder->build_object({ |
| 299 |
class => 'Koha::ItemTypes', |
| 300 |
value => { |
| 301 |
rentalcharge => 10 |
| 302 |
} |
| 303 |
}); |
| 304 |
my $itype_no_charge = $builder->build_object({ |
| 305 |
class => 'Koha::ItemTypes', |
| 306 |
value => { |
| 307 |
rentalcharge => 0 |
| 308 |
} |
| 309 |
}); |
| 310 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 311 |
my $item_1 = $builder->build_sample_item({ itype => $itype_charge->itemtype }); |
| 312 |
my $item_2 = $builder->build_sample_item({ itype => $itype_no_charge->itemtype }); |
| 313 |
|
| 314 |
t::lib::Mocks::mock_userenv({ branchcode => $branch_no_discount->branchcode }); |
| 315 |
# For now the sub always uses the env branch, this should follow CircControl instead |
| 316 |
my ($charge, $itemtype) = GetIssuingCharges( $item_1->itemnumber, $patron->borrowernumber); |
| 317 |
is( $charge + 0, 10.00, "Charge fetched correctly when no discount exists"); |
| 318 |
($charge, $itemtype) = GetIssuingCharges( $item_2->itemnumber, $patron->borrowernumber); |
| 319 |
is( $charge + 0, 0.00, "Charge fetched correctly when no discount exists and no charge"); |
| 320 |
|
| 321 |
t::lib::Mocks::mock_userenv({ branchcode => $branch_discount->branchcode }); |
| 322 |
# For now the sub always uses the env branch, this should follow CircControl instead |
| 323 |
($charge, $itemtype) = GetIssuingCharges( $item_1->itemnumber, $patron->borrowernumber); |
| 324 |
is( $charge + 0, 8.50, "Charge fetched correctly when discount exists"); |
| 325 |
($charge, $itemtype) = GetIssuingCharges( $item_2->itemnumber, $patron->borrowernumber); |
| 326 |
is( $charge + 0, 0.00, "Charge fetched correctly when discount exists and no charge"); |
| 327 |
|
| 328 |
}; |
| 329 |
|
| 285 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
330 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
| 286 |
subtest "CanBookBeRenewed tests" => sub { |
331 |
subtest "CanBookBeRenewed tests" => sub { |
| 287 |
plan tests => 89; |
332 |
plan tests => 89; |
| 288 |
- |
|
|