|
Lines 30-36
use Koha::CirculationRules;
Link Here
|
| 30 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
| 31 |
use t::lib::Mocks; |
31 |
use t::lib::Mocks; |
| 32 |
|
32 |
|
| 33 |
use Test::More tests => 19; |
33 |
use Test::More tests => 21; |
| 34 |
|
34 |
|
| 35 |
my $dbh = C4::Context->dbh; |
35 |
my $dbh = C4::Context->dbh; |
| 36 |
my $schema = Koha::Database->new()->schema(); |
36 |
my $schema = Koha::Database->new()->schema(); |
|
Lines 109-119
Koha::CirculationRules->set_rules(
Link Here
|
| 109 |
lengthunit => 'days', |
109 |
lengthunit => 'days', |
| 110 |
reservesallowed => '99', |
110 |
reservesallowed => '99', |
| 111 |
holds_per_record => '99', |
111 |
holds_per_record => '99', |
|
|
112 |
decreaseloanholds => 0, |
| 112 |
} |
113 |
} |
| 113 |
} |
114 |
} |
| 114 |
); |
115 |
); |
| 115 |
|
116 |
|
| 116 |
|
|
|
| 117 |
my $orig_due = C4::Circulation::CalcDateDue( |
117 |
my $orig_due = C4::Circulation::CalcDateDue( |
| 118 |
dt_from_string(), |
118 |
dt_from_string(), |
| 119 |
$item->effective_itemtype, |
119 |
$item->effective_itemtype, |
|
Lines 133-141
my $patron_hr = { borrowernumber => $patron->id, branchcode => $library->{branch
Link Here
|
| 133 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
133 |
my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 134 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
134 |
is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); |
| 135 |
is( $data->{outstanding}, 6, "Should have 6 outstanding holds" ); |
135 |
is( $data->{outstanding}, 6, "Should have 6 outstanding holds" ); |
| 136 |
is( $data->{duration}, 1, "Should have duration of 1" ); |
136 |
is( $data->{duration}, 0, "Should have duration of 0 because of specific circulation rules" ); |
| 137 |
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); |
137 |
is( ref( $data->{due_date} ), 'DateTime', "due_date should be a DateTime object" ); |
| 138 |
|
138 |
|
|
|
139 |
Koha::CirculationRules->set_rules( |
| 140 |
{ |
| 141 |
branchcode => undef, |
| 142 |
categorycode => undef, |
| 143 |
itemtype => $item->itype, |
| 144 |
rules => { |
| 145 |
issuelength => '14', |
| 146 |
lengthunit => 'days', |
| 147 |
reservesallowed => '99', |
| 148 |
holds_per_record => '99', |
| 149 |
decreaseloanholds => undef, |
| 150 |
} |
| 151 |
} |
| 152 |
); |
| 153 |
|
| 154 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 155 |
is( $data->{duration}, 1, "Should have a duration of 1 because no specific circulation rules so defaults to system preference" ); |
| 156 |
|
| 139 |
my $duedate = $data->{due_date}; |
157 |
my $duedate = $data->{due_date}; |
| 140 |
is($duedate->hour, $orig_due->hour, 'New due hour is equal to original due hour.'); |
158 |
is($duedate->hour, $orig_due->hour, 'New due hour is equal to original due hour.'); |
| 141 |
is($duedate->min, $orig_due->min, 'New due minute is equal to original due minute.'); |
159 |
is($duedate->min, $orig_due->min, 'New due minute is equal to original due minute.'); |
|
Lines 215-218
ok( $needsconfirmation->{HIGHHOLDS}, "High holds checkout needs confirmation" );
Link Here
|
| 215 |
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode, undef, undef, undef, { override_high_holds => 1 } ); |
233 |
( undef, $needsconfirmation ) = CanBookBeIssued( $patron_object, $item->barcode, undef, undef, undef, { override_high_holds => 1 } ); |
| 216 |
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" ); |
234 |
ok( !$needsconfirmation->{HIGHHOLDS}, "High holds checkout does not need confirmation" ); |
| 217 |
|
235 |
|
|
|
236 |
Koha::CirculationRules->set_rule( |
| 237 |
{ |
| 238 |
branchcode => undef, |
| 239 |
categorycode => undef, |
| 240 |
itemtype => $item->itype, |
| 241 |
rule_name => 'decreaseloanholds', |
| 242 |
rule_value => 2, |
| 243 |
} |
| 244 |
); |
| 245 |
|
| 246 |
$data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); |
| 247 |
is( $data->{duration}, 2, "Circulation rules override system preferences" ); |
| 248 |
|
| 218 |
$schema->storage->txn_rollback(); |
249 |
$schema->storage->txn_rollback(); |
| 219 |
- |
|
|