|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
use utf8; |
19 |
use utf8; |
| 20 |
|
20 |
|
| 21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
| 22 |
use Test::More tests => 76; |
22 |
use Test::More tests => 77; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use Test::Deep qw( cmp_deeply ); |
25 |
use Test::Deep qw( cmp_deeply ); |
|
Lines 1902-1908
subtest "CanBookBeRenewed | bookings" => sub {
Link Here
|
| 1902 |
my $schema = Koha::Database->schema; |
1902 |
my $schema = Koha::Database->schema; |
| 1903 |
$schema->storage->txn_begin; |
1903 |
$schema->storage->txn_begin; |
| 1904 |
|
1904 |
|
| 1905 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'date_due' ); |
1905 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'date_due' ); |
|
|
1906 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 1906 |
|
1907 |
|
| 1907 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1908 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1908 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1909 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
Lines 7400-7405
subtest 'NoRefundOnLostFinesPaidAge' => sub {
Link Here
|
| 7400 |
); |
7401 |
); |
| 7401 |
}; |
7402 |
}; |
| 7402 |
|
7403 |
|
|
|
7404 |
subtest 'ChildNeedsGuarantor' => sub { |
| 7405 |
plan tests => 18; |
| 7406 |
|
| 7407 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 7408 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 7409 |
my $child_category = $builder->build_object( |
| 7410 |
{ |
| 7411 |
class => 'Koha::Patron::Categories', |
| 7412 |
value => { |
| 7413 |
category_type => 'C', |
| 7414 |
enrolmentfee => 0, |
| 7415 |
} |
| 7416 |
} |
| 7417 |
); |
| 7418 |
my $guarantee_category = $builder->build_object( |
| 7419 |
{ |
| 7420 |
class => 'Koha::Patron::Categories', |
| 7421 |
value => { |
| 7422 |
category_type => 'P', |
| 7423 |
enrolmentfee => 0, |
| 7424 |
can_be_guarantee => 1, |
| 7425 |
} |
| 7426 |
} |
| 7427 |
); |
| 7428 |
my $guarantor_category = $builder->build_object( |
| 7429 |
{ |
| 7430 |
class => 'Koha::Patron::Categories', |
| 7431 |
value => { |
| 7432 |
category_type => 'P', |
| 7433 |
enrolmentfee => 0, |
| 7434 |
can_be_guarantee => 0, |
| 7435 |
} |
| 7436 |
} |
| 7437 |
); |
| 7438 |
my $child_patron = $builder->build_object( |
| 7439 |
{ |
| 7440 |
class => 'Koha::Patrons', |
| 7441 |
value => { categorycode => $child_category->categorycode, contactname => '' } |
| 7442 |
} |
| 7443 |
); |
| 7444 |
my $guarantee_patron = $builder->build_object( |
| 7445 |
{ |
| 7446 |
class => 'Koha::Patrons', |
| 7447 |
value => { categorycode => $guarantee_category->categorycode, contactname => '' } |
| 7448 |
} |
| 7449 |
); |
| 7450 |
my $guarantor_patron = $builder->build_object( |
| 7451 |
{ |
| 7452 |
class => 'Koha::Patrons', |
| 7453 |
value => { categorycode => $guarantee_category->categorycode, contactname => '' } |
| 7454 |
} |
| 7455 |
); |
| 7456 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
| 7457 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'check_in,check_out,renewal' ); |
| 7458 |
|
| 7459 |
my $biblionumber = $builder->build_sample_biblio( |
| 7460 |
{ |
| 7461 |
branchcode => $library->branchcode, |
| 7462 |
} |
| 7463 |
)->biblionumber; |
| 7464 |
|
| 7465 |
Koha::CirculationRules->set_rules( |
| 7466 |
{ |
| 7467 |
categorycode => undef, |
| 7468 |
itemtype => undef, |
| 7469 |
branchcode => $library->branchcode, |
| 7470 |
rules => { |
| 7471 |
issuelength => 14, |
| 7472 |
lengthunit => 'days', |
| 7473 |
} |
| 7474 |
} |
| 7475 |
); |
| 7476 |
|
| 7477 |
my $item = $builder->build_sample_item( |
| 7478 |
{ |
| 7479 |
biblionumber => $biblionumber, |
| 7480 |
library => $library->branchcode, |
| 7481 |
} |
| 7482 |
); |
| 7483 |
warnings_like { |
| 7484 |
AddIssue( $child_patron, $item->barcode, undef ); |
| 7485 |
} |
| 7486 |
qr/Problem updating lastseen/, |
| 7487 |
"AddIssue generates a warning when Child type patron is missing a guarantor and ChildsNeedsGuarantor"; |
| 7488 |
warnings_like { |
| 7489 |
AddRenewal( |
| 7490 |
{ |
| 7491 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7492 |
branch => $library->branchcode |
| 7493 |
} |
| 7494 |
); |
| 7495 |
} |
| 7496 |
qr/Problem updating lastseen/, |
| 7497 |
"AddRenewal generates a warning when Child type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7498 |
warnings_like { |
| 7499 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7500 |
} |
| 7501 |
qr/Problem updating lastseen/, |
| 7502 |
"AddReturn generates a warning when Child type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7503 |
|
| 7504 |
warnings_like { |
| 7505 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
| 7506 |
} |
| 7507 |
qr/Problem updating lastseen/, |
| 7508 |
"AddIssue generates a warning when can_be_guarantee type patron is missing a guarantor and ChildsNeedsGuarantor"; |
| 7509 |
warnings_like { |
| 7510 |
AddRenewal( |
| 7511 |
{ |
| 7512 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7513 |
branch => $library->branchcode |
| 7514 |
} |
| 7515 |
); |
| 7516 |
} |
| 7517 |
qr/Problem updating lastseen/, |
| 7518 |
"AddRenewal generates a warning when can_be_guarantee type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7519 |
warnings_like { |
| 7520 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7521 |
} |
| 7522 |
qr/Problem updating lastseen/, |
| 7523 |
"AddReturn generates a warning when can_be_guarantee type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7524 |
|
| 7525 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 7526 |
warnings_like { |
| 7527 |
AddIssue( $child_patron, $item->barcode, undef ); |
| 7528 |
} |
| 7529 |
undef, "AddIssue generates no warning when Child type patron is missing a guarantor and not ChildsNeedsGuarantor"; |
| 7530 |
warnings_like { |
| 7531 |
AddRenewal( |
| 7532 |
{ |
| 7533 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7534 |
branch => $library->branchcode |
| 7535 |
} |
| 7536 |
); |
| 7537 |
} |
| 7538 |
undef, "AddRenewal generates no warning when Child type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7539 |
warnings_like { |
| 7540 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7541 |
} |
| 7542 |
undef, "AddReturn generates no warning when Child type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7543 |
|
| 7544 |
warnings_like { |
| 7545 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
| 7546 |
} |
| 7547 |
undef, |
| 7548 |
"AddIssue generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildsNeedsGuarantor"; |
| 7549 |
warnings_like { |
| 7550 |
AddRenewal( |
| 7551 |
{ |
| 7552 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7553 |
branch => $library->branchcode |
| 7554 |
} |
| 7555 |
); |
| 7556 |
} |
| 7557 |
undef, |
| 7558 |
"AddRenewal generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7559 |
warnings_like { |
| 7560 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7561 |
} |
| 7562 |
undef, |
| 7563 |
"AddReturn generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7564 |
|
| 7565 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
| 7566 |
$child_patron->contactname("Anybody")->store; |
| 7567 |
warnings_like { |
| 7568 |
AddIssue( $child_patron, $item->barcode, undef ); |
| 7569 |
} |
| 7570 |
undef, "AddIssue generates no warning when Child type patron has a guarantor and ChildsNeedsGuarantor"; |
| 7571 |
warnings_like { |
| 7572 |
AddRenewal( |
| 7573 |
{ |
| 7574 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7575 |
branch => $library->branchcode |
| 7576 |
} |
| 7577 |
); |
| 7578 |
} |
| 7579 |
undef, "AddRenewal generates no warning when Child type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7580 |
warnings_like { |
| 7581 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7582 |
} |
| 7583 |
undef, "AddReturn generates no warning when Child type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7584 |
|
| 7585 |
$guarantee_patron->add_guarantor( { guarantor_id => $guarantor_patron->borrowernumber, relationship => 'father' } ); |
| 7586 |
warnings_like { |
| 7587 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
| 7588 |
} |
| 7589 |
undef, |
| 7590 |
"AddIssue generates no warning when can_be_guarantee type patron has a guarantor and not ChildsNeedsGuarantor"; |
| 7591 |
warnings_like { |
| 7592 |
AddRenewal( |
| 7593 |
{ |
| 7594 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7595 |
branch => $library->branchcode |
| 7596 |
} |
| 7597 |
); |
| 7598 |
} |
| 7599 |
undef, |
| 7600 |
"AddRenewal generates no warning when can_be_guarantee type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7601 |
warnings_like { |
| 7602 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7603 |
} |
| 7604 |
undef, |
| 7605 |
"AddReturn generates no warning when can_be_guarantee type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7606 |
}; |
| 7607 |
|
| 7403 |
$schema->storage->txn_rollback; |
7608 |
$schema->storage->txn_rollback; |
| 7404 |
C4::Context->clear_syspref_cache(); |
7609 |
C4::Context->clear_syspref_cache(); |
| 7405 |
$branches = Koha::Libraries->search(); |
7610 |
$branches = Koha::Libraries->search(); |
| 7406 |
- |
|
|