|
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 => 75; |
21 |
use Test::More tests => 76; |
| 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 1801-1807
subtest "CanBookBeRenewed | bookings" => sub {
Link Here
|
| 1801 |
my $schema = Koha::Database->schema; |
1801 |
my $schema = Koha::Database->schema; |
| 1802 |
$schema->storage->txn_begin; |
1802 |
$schema->storage->txn_begin; |
| 1803 |
|
1803 |
|
| 1804 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'date_due' ); |
1804 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'date_due' ); |
|
|
1805 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 1805 |
|
1806 |
|
| 1806 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1807 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1807 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1808 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
Lines 6920-6925
subtest 'NoRefundOnLostFinesPaidAge' => sub {
Link Here
|
| 6920 |
); |
6921 |
); |
| 6921 |
}; |
6922 |
}; |
| 6922 |
|
6923 |
|
|
|
6924 |
subtest 'ChildNeedsGuarantor' => sub { |
| 6925 |
plan tests => 18; |
| 6926 |
|
| 6927 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 6928 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 6929 |
my $child_category = $builder->build_object( |
| 6930 |
{ |
| 6931 |
class => 'Koha::Patron::Categories', |
| 6932 |
value => { |
| 6933 |
category_type => 'C', |
| 6934 |
enrolmentfee => 0, |
| 6935 |
} |
| 6936 |
} |
| 6937 |
); |
| 6938 |
my $guarantee_category = $builder->build_object( |
| 6939 |
{ |
| 6940 |
class => 'Koha::Patron::Categories', |
| 6941 |
value => { |
| 6942 |
category_type => 'P', |
| 6943 |
enrolmentfee => 0, |
| 6944 |
can_be_guarantee => 1, |
| 6945 |
} |
| 6946 |
} |
| 6947 |
); |
| 6948 |
my $guarantor_category = $builder->build_object( |
| 6949 |
{ |
| 6950 |
class => 'Koha::Patron::Categories', |
| 6951 |
value => { |
| 6952 |
category_type => 'P', |
| 6953 |
enrolmentfee => 0, |
| 6954 |
can_be_guarantee => 0, |
| 6955 |
} |
| 6956 |
} |
| 6957 |
); |
| 6958 |
my $child_patron = $builder->build_object( |
| 6959 |
{ |
| 6960 |
class => 'Koha::Patrons', |
| 6961 |
value => { categorycode => $child_category->categorycode, contactname => '' } |
| 6962 |
} |
| 6963 |
); |
| 6964 |
my $guarantee_patron = $builder->build_object( |
| 6965 |
{ |
| 6966 |
class => 'Koha::Patrons', |
| 6967 |
value => { categorycode => $guarantee_category->categorycode, contactname => '' } |
| 6968 |
} |
| 6969 |
); |
| 6970 |
my $guarantor_patron = $builder->build_object( |
| 6971 |
{ |
| 6972 |
class => 'Koha::Patrons', |
| 6973 |
value => { categorycode => $guarantee_category->categorycode, contactname => '' } |
| 6974 |
} |
| 6975 |
); |
| 6976 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
| 6977 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'check_in,check_out,renewal' ); |
| 6978 |
|
| 6979 |
my $biblionumber = $builder->build_sample_biblio( |
| 6980 |
{ |
| 6981 |
branchcode => $library->branchcode, |
| 6982 |
} |
| 6983 |
)->biblionumber; |
| 6984 |
|
| 6985 |
Koha::CirculationRules->set_rules( |
| 6986 |
{ |
| 6987 |
categorycode => undef, |
| 6988 |
itemtype => undef, |
| 6989 |
branchcode => $library->branchcode, |
| 6990 |
rules => { |
| 6991 |
issuelength => 14, |
| 6992 |
lengthunit => 'days', |
| 6993 |
} |
| 6994 |
} |
| 6995 |
); |
| 6996 |
|
| 6997 |
my $item = $builder->build_sample_item( |
| 6998 |
{ |
| 6999 |
biblionumber => $biblionumber, |
| 7000 |
library => $library->branchcode, |
| 7001 |
} |
| 7002 |
); |
| 7003 |
warnings_like { |
| 7004 |
AddIssue( $child_patron, $item->barcode, undef ); |
| 7005 |
} |
| 7006 |
qr/Problem updating lastseen/, |
| 7007 |
"AddIssue generates a warning when Child type patron is missing a guarantor and ChildsNeedsGuarantor"; |
| 7008 |
warnings_like { |
| 7009 |
AddRenewal( |
| 7010 |
{ |
| 7011 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7012 |
branch => $library->branchcode |
| 7013 |
} |
| 7014 |
); |
| 7015 |
} |
| 7016 |
qr/Problem updating lastseen/, |
| 7017 |
"AddRenewal generates a warning when Child type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7018 |
warnings_like { |
| 7019 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7020 |
} |
| 7021 |
qr/Problem updating lastseen/, |
| 7022 |
"AddReturn generates a warning when Child type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7023 |
|
| 7024 |
warnings_like { |
| 7025 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
| 7026 |
} |
| 7027 |
qr/Problem updating lastseen/, |
| 7028 |
"AddIssue generates a warning when can_be_guarantee type patron is missing a guarantor and ChildsNeedsGuarantor"; |
| 7029 |
warnings_like { |
| 7030 |
AddRenewal( |
| 7031 |
{ |
| 7032 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7033 |
branch => $library->branchcode |
| 7034 |
} |
| 7035 |
); |
| 7036 |
} |
| 7037 |
qr/Problem updating lastseen/, |
| 7038 |
"AddRenewal generates a warning when can_be_guarantee type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7039 |
warnings_like { |
| 7040 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7041 |
} |
| 7042 |
qr/Problem updating lastseen/, |
| 7043 |
"AddReturn generates a warning when can_be_guarantee type patron is missing a guarantor and ChildNeedsGuarantor"; |
| 7044 |
|
| 7045 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 7046 |
warnings_like { |
| 7047 |
AddIssue( $child_patron, $item->barcode, undef ); |
| 7048 |
} |
| 7049 |
undef, "AddIssue generates no warning when Child type patron is missing a guarantor and not ChildsNeedsGuarantor"; |
| 7050 |
warnings_like { |
| 7051 |
AddRenewal( |
| 7052 |
{ |
| 7053 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7054 |
branch => $library->branchcode |
| 7055 |
} |
| 7056 |
); |
| 7057 |
} |
| 7058 |
undef, "AddRenewal generates no warning when Child type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7059 |
warnings_like { |
| 7060 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7061 |
} |
| 7062 |
undef, "AddReturn generates no warning when Child type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7063 |
|
| 7064 |
warnings_like { |
| 7065 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
| 7066 |
} |
| 7067 |
undef, |
| 7068 |
"AddIssue generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildsNeedsGuarantor"; |
| 7069 |
warnings_like { |
| 7070 |
AddRenewal( |
| 7071 |
{ |
| 7072 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7073 |
branch => $library->branchcode |
| 7074 |
} |
| 7075 |
); |
| 7076 |
} |
| 7077 |
undef, |
| 7078 |
"AddRenewal generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7079 |
warnings_like { |
| 7080 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7081 |
} |
| 7082 |
undef, |
| 7083 |
"AddReturn generates no warning when can_be_guarantee type patron is missing a guarantor and not ChildNeedsGuarantor"; |
| 7084 |
|
| 7085 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
| 7086 |
$child_patron->contactname("Anybody")->store; |
| 7087 |
warnings_like { |
| 7088 |
AddIssue( $child_patron, $item->barcode, undef ); |
| 7089 |
} |
| 7090 |
undef, "AddIssue generates no warning when Child type patron has a guarantor and ChildsNeedsGuarantor"; |
| 7091 |
warnings_like { |
| 7092 |
AddRenewal( |
| 7093 |
{ |
| 7094 |
borrowernumber => $child_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7095 |
branch => $library->branchcode |
| 7096 |
} |
| 7097 |
); |
| 7098 |
} |
| 7099 |
undef, "AddRenewal generates no warning when Child type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7100 |
warnings_like { |
| 7101 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7102 |
} |
| 7103 |
undef, "AddReturn generates no warning when Child type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7104 |
|
| 7105 |
$guarantee_patron->add_guarantor( { guarantor_id => $guarantor_patron->borrowernumber, relationship => 'father' } ); |
| 7106 |
warnings_like { |
| 7107 |
AddIssue( $guarantee_patron, $item->barcode, undef ); |
| 7108 |
} |
| 7109 |
undef, |
| 7110 |
"AddIssue generates no warning when can_be_guarantee type patron has a guarantor and not ChildsNeedsGuarantor"; |
| 7111 |
warnings_like { |
| 7112 |
AddRenewal( |
| 7113 |
{ |
| 7114 |
borrowernumber => $guarantee_patron->borrowernumber, itemnumber => $item->itemnumber, |
| 7115 |
branch => $library->branchcode |
| 7116 |
} |
| 7117 |
); |
| 7118 |
} |
| 7119 |
undef, |
| 7120 |
"AddRenewal generates no warning when can_be_guarantee type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7121 |
warnings_like { |
| 7122 |
AddReturn( $item->barcode, $library->branchcode, undef, undef ); |
| 7123 |
} |
| 7124 |
undef, |
| 7125 |
"AddReturn generates no warning when can_be_guarantee type patron has a guarantor and not ChildNeedsGuarantor"; |
| 7126 |
}; |
| 6923 |
|
7127 |
|
| 6924 |
$schema->storage->txn_rollback; |
7128 |
$schema->storage->txn_rollback; |
| 6925 |
C4::Context->clear_syspref_cache(); |
7129 |
C4::Context->clear_syspref_cache(); |
| 6926 |
- |
|
|