Lines 8-14
use C4::Circulation;
Link Here
|
8 |
use C4::Items; |
8 |
use C4::Items; |
9 |
use C4::Context; |
9 |
use C4::Context; |
10 |
|
10 |
|
11 |
use Test::More tests => 10; |
11 |
use Test::More tests => 11; |
12 |
|
12 |
|
13 |
BEGIN { |
13 |
BEGIN { |
14 |
use_ok('C4::Circulation'); |
14 |
use_ok('C4::Circulation'); |
Lines 160-179
$sth->execute(
Link Here
|
160 |
$sampleitemtype2->{imageurl}, $sampleitemtype2->{summary} |
160 |
$sampleitemtype2->{imageurl}, $sampleitemtype2->{summary} |
161 |
); |
161 |
); |
162 |
|
162 |
|
163 |
$query = |
163 |
is_deeply( |
164 |
"INSERT INTO branch_borrower_circ_rules (branchcode,categorycode,maxissueqty) VALUES( ?,?,?)"; |
164 |
GetBranchBorrowerCircRule(), |
|
|
165 |
{ maxissueqty => undef, maxonsiteissueqty => undef }, |
166 |
"Without parameter, GetBranchBorrower returns undef (unilimited) for maxissueqty and maxonsiteissueqty if no rules defined" |
167 |
); |
168 |
|
169 |
$query = q| |
170 |
INSERT INTO branch_borrower_circ_rules |
171 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
172 |
VALUES( ?, ?, ?, ?) |
173 |
|; |
165 |
$dbh->do( |
174 |
$dbh->do( |
166 |
$query, {}, |
175 |
$query, {}, |
167 |
$samplebranch1->{branchcode}, |
176 |
$samplebranch1->{branchcode}, |
168 |
$samplecat->{categorycode}, 5 |
177 |
$samplecat->{categorycode}, 5, 6 |
169 |
); |
178 |
); |
170 |
$query = |
179 |
$query = q| |
171 |
"INSERT INTO default_branch_circ_rules (branchcode,maxissueqty,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
180 |
INSERT INTO default_branch_circ_rules |
|
|
181 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
182 |
VALUES( ?, ?, ?, ?, ?) |
183 |
|; |
172 |
$dbh->do( $query, {}, $samplebranch2->{branchcode}, |
184 |
$dbh->do( $query, {}, $samplebranch2->{branchcode}, |
173 |
3, 1, $samplebranch2->{branchcode} ); |
185 |
3, 2, 1, $samplebranch2->{branchcode} ); |
174 |
$query = |
186 |
$query = q| |
175 |
"INSERT INTO default_circ_rules (singleton,maxissueqty,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
187 |
INSERT INTO default_circ_rules |
176 |
$dbh->do( $query, {}, 'singleton', 4, 3, $samplebranch1->{branchcode} ); |
188 |
(singleton, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
|
|
189 |
VALUES( ?, ?, ?, ?, ? ) |
190 |
|; |
191 |
$dbh->do( $query, {}, 'singleton', 4, 5, 3, $samplebranch1->{branchcode} ); |
177 |
|
192 |
|
178 |
$query = |
193 |
$query = |
179 |
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
194 |
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
Lines 192-217
$sth->execute(
Link Here
|
192 |
#Test GetBranchBorrowerCircRule |
207 |
#Test GetBranchBorrowerCircRule |
193 |
is_deeply( |
208 |
is_deeply( |
194 |
GetBranchBorrowerCircRule(), |
209 |
GetBranchBorrowerCircRule(), |
195 |
{ maxissueqty => 4 }, |
210 |
{ maxissueqty => 4, maxonsiteissueqty => 5 }, |
196 |
"Without parameter, GetBranchBorrower returns the maxissueqty of default_circ_rules" |
211 |
"Without parameter, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of default_circ_rules" |
197 |
); |
212 |
); |
198 |
is_deeply( |
213 |
is_deeply( |
199 |
GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ), |
214 |
GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ), |
200 |
{ maxissueqty => 3 }, |
215 |
{ maxissueqty => 3, maxonsiteissueqty => 2 }, |
201 |
"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty corresponding" |
216 |
"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty corresponding" |
202 |
); |
217 |
); |
203 |
is_deeply( |
218 |
is_deeply( |
204 |
GetBranchBorrowerCircRule( |
219 |
GetBranchBorrowerCircRule( |
205 |
$samplebranch1->{branchcode}, |
220 |
$samplebranch1->{branchcode}, |
206 |
$samplecat->{categorycode} |
221 |
$samplecat->{categorycode} |
207 |
), |
222 |
), |
208 |
{ maxissueqty => 5 }, |
223 |
{ maxissueqty => 5, maxonsiteissueqty => 6 }, |
209 |
"GetBranchBorrower returns the maxissueqty of the branch1 and the category1" |
224 |
"GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of the branch1 and the category1" |
210 |
); |
225 |
); |
211 |
is_deeply( |
226 |
is_deeply( |
212 |
GetBranchBorrowerCircRule( -1, -1 ), |
227 |
GetBranchBorrowerCircRule( -1, -1 ), |
213 |
{ maxissueqty => 4 }, |
228 |
{ maxissueqty => 4, maxonsiteissueqty => 5 }, |
214 |
"GetBranchBorrower with wrong parameters returns tthe maxissueqty of default_circ_rules" |
229 |
"GetBranchBorrower with wrong parameters returns the maxissueqty and maxonsiteissueqty of default_circ_rules" |
215 |
); |
230 |
); |
216 |
|
231 |
|
217 |
#Test GetBranchItemRule |
232 |
#Test GetBranchItemRule |
Lines 236-242
is_deeply(
Link Here
|
236 |
is_deeply( |
251 |
is_deeply( |
237 |
GetBranchItemRule( -1, -1 ), |
252 |
GetBranchItemRule( -1, -1 ), |
238 |
{ returnbranch => $samplebranch1->{branchcode}, holdallowed => 3 }, |
253 |
{ returnbranch => $samplebranch1->{branchcode}, holdallowed => 3 }, |
239 |
"With only one parametern GetBranchItemRule returns default values" |
254 |
"With only one parameter GetBranchItemRule returns default values" |
240 |
); |
255 |
); |
241 |
|
256 |
|
242 |
$dbh->rollback; |
257 |
$dbh->rollback; |