Lines 15-21
Link Here
|
15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
|
16 |
|
17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
18 |
use Test::More tests => 8; |
18 |
use Test::More tests => 9; |
19 |
use C4::Context; |
19 |
use C4::Context; |
20 |
|
20 |
|
21 |
use C4::Biblio; |
21 |
use C4::Biblio; |
Lines 94-109
C4::Circulation::AddIssue( $patron, $item->{barcode}, dt_from_string, undef, dt_
Link Here
|
94 |
my ( $impossible, $messages ); |
94 |
my ( $impossible, $messages ); |
95 |
t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0); |
95 |
t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0); |
96 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
96 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
97 |
is( $impossible->{NO_RENEWAL_FOR_ONSITE_CHECKOUTS}, 1, '' ); |
97 |
is( $impossible->{NO_RENEWAL_FOR_ONSITE_CHECKOUTS}, 1, 'Do not renew on-site checkouts' ); |
98 |
|
98 |
|
99 |
t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 1); |
99 |
t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 1); |
100 |
( undef, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
100 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); |
101 |
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' ); |
101 |
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' ); |
|
|
102 |
is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' ); |
102 |
C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } ); |
103 |
C4::Circulation::AddIssue( $patron, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } ); |
103 |
my $issue = C4::Circulation::GetItemIssue( $item->{itemnumber} ); |
104 |
my $issue = C4::Circulation::GetItemIssue( $item->{itemnumber} ); |
104 |
is( $issue->{onsite_checkout}, 0, '' ); |
105 |
is( $issue->{onsite_checkout}, 0, 'The issue should have been switched to a regular checkout' ); |
105 |
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 ); |
106 |
my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 ); |
106 |
is( $issue->{date_due}, $five_days_after ); |
107 |
is( $issue->{date_due}, $five_days_after, 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched' ); |
107 |
|
108 |
|
108 |
# Specific case |
109 |
# Specific case |
109 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
110 |
t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); |
Lines 118-125
my $another_item = $builder->build({
Link Here
|
118 |
|
119 |
|
119 |
C4::Circulation::AddIssue( $patron, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); |
120 |
C4::Circulation::AddIssue( $patron, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); |
120 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); |
121 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); |
121 |
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' ); |
122 |
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 1 - Switch is allowed' ); |
122 |
is( exists $impossible->{TOO_MANY}, '', '' ); |
123 |
is( exists $impossible->{TOO_MANY}, '', 'Specific case 1 - Switch is allowed' ); |
123 |
|
124 |
|
124 |
$dbh->do(q|DELETE FROM issuingrules|); |
125 |
$dbh->do(q|DELETE FROM issuingrules|); |
125 |
my $borrower_circ_rule = $builder->build({ |
126 |
my $borrower_circ_rule = $builder->build({ |
Lines 132-139
my $borrower_circ_rule = $builder->build({
Link Here
|
132 |
}, |
133 |
}, |
133 |
}); |
134 |
}); |
134 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); |
135 |
( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); |
135 |
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, '' ); |
136 |
is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 2 - Switch is allowed' ); |
136 |
is( exists $impossible->{TOO_MANY}, '', '' ); |
137 |
is( exists $impossible->{TOO_MANY}, '', 'Specific case 2 - Switch is allowed' ); |
137 |
|
138 |
|
138 |
$schema->storage->txn_rollback; |
139 |
$schema->storage->txn_rollback; |
139 |
|
140 |
|
140 |
- |
|
|