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 7438-7443
subtest 'NoRefundOnLostFinesPaidAge' => sub {
Link Here
|
7438 |
); |
7439 |
); |
7439 |
}; |
7440 |
}; |
7440 |
|
7441 |
|
|
|
7442 |
subtest 'ChildNeedsGuarantor' => sub { |
7443 |
plan tests => 18; |
7444 |
|
7445 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
7446 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
7447 |
my $child_category = $builder->build_object( |
7448 |
{ |
7449 |
class => 'Koha::Patron::Categories', |
7450 |
value => { |
7451 |
category_type => 'C', |
7452 |
enrolmentfee => 0, |
7453 |
} |
7454 |
} |
7455 |
); |
7456 |
my $guarantee_category = $builder->build_object( |
7457 |
{ |
7458 |
class => 'Koha::Patron::Categories', |
7459 |
value => { |
7460 |
category_type => 'P', |
7461 |
enrolmentfee => 0, |
7462 |
can_be_guarantee => 1, |
7463 |
} |
7464 |
} |
7465 |
); |
7466 |
my $guarantor_category = $builder->build_object( |
7467 |
{ |
7468 |
class => 'Koha::Patron::Categories', |
7469 |
value => { |
7470 |
category_type => 'P', |
7471 |
enrolmentfee => 0, |
7472 |
can_be_guarantee => 0, |
7473 |
} |
7474 |
} |
7475 |
); |
7476 |
my $child_patron = $builder->build_object( |
7477 |
{ |
7478 |
class => 'Koha::Patrons', |
7479 |
value => { categorycode => $child_category->categorycode, contactname => '' } |
7480 |
} |
7481 |
); |
7482 |
my $guarantee_patron = $builder->build_object( |
7483 |
{ |
7484 |
class => 'Koha::Patrons', |
7485 |
value => { categorycode => $guarantee_category->categorycode, contactname => '' } |
7486 |
} |
7487 |
); |
7488 |
my $guarantor_patron = $builder->build_object( |
7489 |
{ |
7490 |
class => 'Koha::Patrons', |
7491 |
value => { categorycode => $guarantee_category->categorycode, contactname => '' } |
7492 |
} |
7493 |
); |
7494 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
7495 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'check_in,check_out,renewal' ); |
7496 |
|
7497 |
my $biblionumber = $builder->build_sample_biblio( |
7498 |
{ |
7499 |
branchcode => $library->branchcode, |
7500 |
} |
7501 |
)->biblionumber; |
7502 |
|
7503 |
Koha::CirculationRules->set_rules( |
7504 |
{ |
7505 |
categorycode => undef, |
7506 |
itemtype => undef, |
7507 |
branchcode => $library->branchcode, |
7508 |
rules => { |
7509 |
issuelength => 14, |
7510 |
lengthunit => 'days', |
7511 |
} |
7512 |
} |
7513 |
); |
7514 |
|
7515 |
my $item = $builder->build_sample_item( |
7516 |
{ |
7517 |
biblionumber => $biblionumber, |
7518 |
library => $library->branchcode, |
7519 |
} |
7520 |
); |
7521 |
warnings_like { |
7522 |
AddIssue( $child_patron, $item->barcode, undef ); |
7523 |
} |
7524 |
qr/Problem updating lastseen/, |
7525 |
"AddIssue generates a warning when Child type patron is missing a guarantor and ChildsNeedsGuarantor"; |
7526 |
warnings_like { |
7527 |
AddRenewal( |
7528 |
{ |
7529 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
7530 |
branch => $library->branchcode |
7531 |
} |
7532 |
); |
7533 |
} |
7534 |
qr/Problem updating lastseen/, |
7535 |
"AddRenewal generates a warning when Child type patron is missing a guarantor and ChildNeedsGuarantor"; |
7536 |
warnings_like { |
7537 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
7538 |
} |
7539 |
qr/Problem updating lastseen/, |
7540 |
"AddReturn generates a warning when Child type patron is missing a guarantor and ChildNeedsGuarantor"; |
7541 |
|
7542 |
warnings_like { |
7543 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
7544 |
} |
7545 |
qr/Problem updating lastseen/, |
7546 |
"AddIssue generates a warning when can_be_guarantee type patron is missing a guarantor and ChildsNeedsGuarantor"; |
7547 |
warnings_like { |
7548 |
AddRenewal( |
7549 |
{ |
7550 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
7551 |
branch => $library->branchcode |
7552 |
} |
7553 |
); |
7554 |
} |
7555 |
qr/Problem updating lastseen/, |
7556 |
"AddRenewal generates a warning when can_be_guarantee type patron is missing a guarantor and ChildNeedsGuarantor"; |
7557 |
warnings_like { |
7558 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
7559 |
} |
7560 |
qr/Problem updating lastseen/, |
7561 |
"AddReturn generates a warning when can_be_guarantee type patron is missing a guarantor and ChildNeedsGuarantor"; |
7562 |
|
7563 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
7564 |
warnings_like { |
7565 |
AddIssue( $child_patron, $item->barcode, undef ); |
7566 |
} |
7567 |
undef, "AddIssue generates no warning when Child type patron is missing a guarantor and not ChildsNeedsGuarantor"; |
7568 |
warnings_like { |
7569 |
AddRenewal( |
7570 |
{ |
7571 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
7572 |
branch => $library->branchcode |
7573 |
} |
7574 |
); |
7575 |
} |
7576 |
undef, "AddRenewal generates no warning when Child type patron is missing a guarantor and not ChildNeedsGuarantor"; |
7577 |
warnings_like { |
7578 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
7579 |
} |
7580 |
undef, "AddReturn generates no warning when Child type patron is missing a guarantor and not ChildNeedsGuarantor"; |
7581 |
|
7582 |
warnings_like { |
7583 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
7584 |
} |
7585 |
undef, |
7586 |
"AddIssue generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildsNeedsGuarantor"; |
7587 |
warnings_like { |
7588 |
AddRenewal( |
7589 |
{ |
7590 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
7591 |
branch => $library->branchcode |
7592 |
} |
7593 |
); |
7594 |
} |
7595 |
undef, |
7596 |
"AddRenewal generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildNeedsGuarantor"; |
7597 |
warnings_like { |
7598 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
7599 |
} |
7600 |
undef, |
7601 |
"AddReturn generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildNeedsGuarantor"; |
7602 |
|
7603 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
7604 |
$child_patron->contactname("Anybody")->store; |
7605 |
warnings_like { |
7606 |
AddIssue( $child_patron, $item->barcode, undef ); |
7607 |
} |
7608 |
undef, "AddIssue generates no warning when Child type patron has a guarantor and ChildsNeedsGuarantor"; |
7609 |
warnings_like { |
7610 |
AddRenewal( |
7611 |
{ |
7612 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
7613 |
branch => $library->branchcode |
7614 |
} |
7615 |
); |
7616 |
} |
7617 |
undef, "AddRenewal generates no warning when Child type patron has a guarantor and not ChildNeedsGuarantor"; |
7618 |
warnings_like { |
7619 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
7620 |
} |
7621 |
undef, "AddReturn generates no warning when Child type patron has a guarantor and not ChildNeedsGuarantor"; |
7622 |
|
7623 |
$guarantee_patron->add_guarantor( { guarantor_id => $guarantor_patron->borrowernumber, relationship => 'father' } ); |
7624 |
warnings_like { |
7625 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
7626 |
} |
7627 |
undef, |
7628 |
"AddIssue generates no warning when can_be_guarantee type patron has a guarantor and not ChildsNeedsGuarantor"; |
7629 |
warnings_like { |
7630 |
AddRenewal( |
7631 |
{ |
7632 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
7633 |
branch => $library->branchcode |
7634 |
} |
7635 |
); |
7636 |
} |
7637 |
undef, |
7638 |
"AddRenewal generates no warning when can_be_guarantee type patron has a guarantor and not ChildNeedsGuarantor"; |
7639 |
warnings_like { |
7640 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
7641 |
} |
7642 |
undef, |
7643 |
"AddReturn generates no warning when can_be_guarantee type patron has a guarantor and not ChildNeedsGuarantor"; |
7644 |
}; |
7645 |
|
7441 |
$schema->storage->txn_rollback; |
7646 |
$schema->storage->txn_rollback; |
7442 |
C4::Context->clear_syspref_cache(); |
7647 |
C4::Context->clear_syspref_cache(); |
7443 |
$branches = Koha::Libraries->search(); |
7648 |
$branches = Koha::Libraries->search(); |
7444 |
- |
|
|