Lines 18-23
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use DateTime; |
20 |
use DateTime; |
|
|
21 |
use t::lib::Mocks; |
21 |
use C4::Biblio; |
22 |
use C4::Biblio; |
22 |
use C4::Branch; |
23 |
use C4::Branch; |
23 |
use C4::Items; |
24 |
use C4::Items; |
Lines 66-72
my $borrower = {
Link Here
|
66 |
}; |
67 |
}; |
67 |
|
68 |
|
68 |
# No userenv, PickupLibrary |
69 |
# No userenv, PickupLibrary |
69 |
C4::Context->set_preference('CircControl', 'PickupLibrary'); |
70 |
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); |
70 |
is( |
71 |
is( |
71 |
C4::Context->preference('CircControl'), |
72 |
C4::Context->preference('CircControl'), |
72 |
'PickupLibrary', |
73 |
'PickupLibrary', |
Lines 79-85
is(
Link Here
|
79 |
); |
80 |
); |
80 |
|
81 |
|
81 |
# No userenv, PatronLibrary |
82 |
# No userenv, PatronLibrary |
82 |
C4::Context->set_preference('CircControl', 'PatronLibrary'); |
83 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
83 |
is( |
84 |
is( |
84 |
C4::Context->preference('CircControl'), |
85 |
C4::Context->preference('CircControl'), |
85 |
'PatronLibrary', |
86 |
'PatronLibrary', |
Lines 92-98
is(
Link Here
|
92 |
); |
93 |
); |
93 |
|
94 |
|
94 |
# No userenv, ItemHomeLibrary |
95 |
# No userenv, ItemHomeLibrary |
95 |
C4::Context->set_preference('CircControl', 'ItemHomeLibrary'); |
96 |
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); |
96 |
is( |
97 |
is( |
97 |
C4::Context->preference('CircControl'), |
98 |
C4::Context->preference('CircControl'), |
98 |
'ItemHomeLibrary', |
99 |
'ItemHomeLibrary', |
Lines 110-116
C4::Context->set_userenv(0,0,0,'firstname','surname', $library2->{branchcode}, '
Link Here
|
110 |
is(C4::Context->userenv->{branch}, $library2->{branchcode}, 'userenv set'); |
111 |
is(C4::Context->userenv->{branch}, $library2->{branchcode}, 'userenv set'); |
111 |
|
112 |
|
112 |
# Userenv set, PickupLibrary |
113 |
# Userenv set, PickupLibrary |
113 |
C4::Context->set_preference('CircControl', 'PickupLibrary'); |
114 |
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); |
114 |
is( |
115 |
is( |
115 |
C4::Context->preference('CircControl'), |
116 |
C4::Context->preference('CircControl'), |
116 |
'PickupLibrary', |
117 |
'PickupLibrary', |
Lines 123-129
is(
Link Here
|
123 |
); |
124 |
); |
124 |
|
125 |
|
125 |
# Userenv set, PatronLibrary |
126 |
# Userenv set, PatronLibrary |
126 |
C4::Context->set_preference('CircControl', 'PatronLibrary'); |
127 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
127 |
is( |
128 |
is( |
128 |
C4::Context->preference('CircControl'), |
129 |
C4::Context->preference('CircControl'), |
129 |
'PatronLibrary', |
130 |
'PatronLibrary', |
Lines 136-142
is(
Link Here
|
136 |
); |
137 |
); |
137 |
|
138 |
|
138 |
# Userenv set, ItemHomeLibrary |
139 |
# Userenv set, ItemHomeLibrary |
139 |
C4::Context->set_preference('CircControl', 'ItemHomeLibrary'); |
140 |
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); |
140 |
is( |
141 |
is( |
141 |
C4::Context->preference('CircControl'), |
142 |
C4::Context->preference('CircControl'), |
142 |
'ItemHomeLibrary', |
143 |
'ItemHomeLibrary', |
Lines 149-155
is(
Link Here
|
149 |
); |
150 |
); |
150 |
|
151 |
|
151 |
# Reset initial configuration |
152 |
# Reset initial configuration |
152 |
C4::Context->set_preference('CircControl', $CircControl); |
153 |
t::lib::Mocks::mock_preference('CircControl', $CircControl); |
153 |
is( |
154 |
is( |
154 |
C4::Context->preference('CircControl'), |
155 |
C4::Context->preference('CircControl'), |
155 |
$CircControl, |
156 |
$CircControl, |
Lines 318-324
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
318 |
|
319 |
|
319 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
320 |
# Testing of feature to allow the renewal of reserved items if other items on the record can fill all needed holds |
320 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
321 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
321 |
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
322 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 1 ); |
322 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
323 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
323 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
324 |
is( $renewokay, 1, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
324 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
325 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
Lines 354-360
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
354 |
is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
355 |
is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
355 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
356 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
356 |
is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
357 |
is( $renewokay, 0, 'Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds'); |
357 |
C4::Context->set_preference('AllowRenewalIfOtherItemsAvailable', 0 ); |
358 |
t::lib::Mocks::mock_preference('AllowRenewalIfOtherItemsAvailable', 0 ); |
358 |
|
359 |
|
359 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
360 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
360 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
361 |
is( $renewokay, 0, '(Bug 10663) Cannot renew, reserved'); |
Lines 410-416
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
410 |
my $datedue5 = AddIssue($restricted_borrower, $barcode5); |
411 |
my $datedue5 = AddIssue($restricted_borrower, $barcode5); |
411 |
is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5"); |
412 |
is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5"); |
412 |
|
413 |
|
413 |
C4::Context->set_preference('RestrictionBlockRenewing','1'); |
414 |
t::lib::Mocks::mock_preference('RestrictionBlockRenewing','1'); |
414 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
415 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
415 |
is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted'); |
416 |
is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted'); |
416 |
( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5); |
417 |
( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5); |
Lines 445-451
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
445 |
is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1"); |
446 |
is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1"); |
446 |
|
447 |
|
447 |
|
448 |
|
448 |
C4::Context->set_preference('OverduesBlockRenewing','blockitem'); |
449 |
t::lib::Mocks::mock_preference('OverduesBlockRenewing','blockitem'); |
449 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
450 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
450 |
is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue'); |
451 |
is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue'); |
451 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
452 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
Lines 486-492
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
486 |
|
487 |
|
487 |
# Bug 14395 |
488 |
# Bug 14395 |
488 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
489 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
489 |
C4::Context->set_preference( 'NoRenewalBeforePrecision', 'exact_time' ); |
490 |
t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'exact_time' ); |
490 |
is( |
491 |
is( |
491 |
GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), |
492 |
GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), |
492 |
$datedue->clone->add( days => -7 ), |
493 |
$datedue->clone->add( days => -7 ), |
Lines 495-501
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
495 |
|
496 |
|
496 |
# Bug 14395 |
497 |
# Bug 14395 |
497 |
# Test 'date' setting for syspref NoRenewalBeforePrecision |
498 |
# Test 'date' setting for syspref NoRenewalBeforePrecision |
498 |
C4::Context->set_preference( 'NoRenewalBeforePrecision', 'date' ); |
499 |
t::lib::Mocks::mock_preference( 'NoRenewalBeforePrecision', 'date' ); |
499 |
is( |
500 |
is( |
500 |
GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), |
501 |
GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), |
501 |
$datedue->clone->add( days => -7 )->truncate( to => 'day' ), |
502 |
$datedue->clone->add( days => -7 )->truncate( to => 'day' ), |
Lines 541-548
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
541 |
is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)'); |
542 |
is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)'); |
542 |
|
543 |
|
543 |
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee |
544 |
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee |
544 |
C4::Context->set_preference('WhenLostForgiveFine','1'); |
545 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','1'); |
545 |
C4::Context->set_preference('WhenLostChargeReplacementFee','1'); |
546 |
t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','1'); |
546 |
|
547 |
|
547 |
C4::Overdues::UpdateFine( |
548 |
C4::Overdues::UpdateFine( |
548 |
{ |
549 |
{ |
Lines 569-576
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
569 |
|
570 |
|
570 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
571 |
C4::Context->dbh->do("DELETE FROM accountlines"); |
571 |
|
572 |
|
572 |
C4::Context->set_preference('WhenLostForgiveFine','0'); |
573 |
t::lib::Mocks::mock_preference('WhenLostForgiveFine','0'); |
573 |
C4::Context->set_preference('WhenLostChargeReplacementFee','0'); |
574 |
t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0'); |
574 |
|
575 |
|
575 |
C4::Overdues::UpdateFine( |
576 |
C4::Overdues::UpdateFine( |
576 |
{ |
577 |
{ |
Lines 602-608
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
602 |
ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); |
603 |
ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); |
603 |
|
604 |
|
604 |
# Users cannot renew any item if there is an overdue item |
605 |
# Users cannot renew any item if there is an overdue item |
605 |
C4::Context->set_preference('OverduesBlockRenewing','block'); |
606 |
t::lib::Mocks::mock_preference('OverduesBlockRenewing','block'); |
606 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
607 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
607 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); |
608 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); |
608 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
609 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
Lines 807-828
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
807 |
); |
808 |
); |
808 |
|
809 |
|
809 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
810 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
810 |
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
811 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
811 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
812 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
812 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
813 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' ); |
813 |
|
814 |
|
814 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
815 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0"); |
815 |
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
816 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
816 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
817 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
817 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
818 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' ); |
818 |
|
819 |
|
819 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
820 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
820 |
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
821 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 0 ); |
821 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
822 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
822 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
823 |
is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' ); |
823 |
|
824 |
|
824 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
825 |
C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1"); |
825 |
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
826 |
t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 ); |
826 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
827 |
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 ); |
827 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
828 |
is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' ); |
828 |
|
829 |
|