Lines 7-14
use C4::Branch;
Link Here
|
7 |
use C4::Circulation; |
7 |
use C4::Circulation; |
8 |
use C4::Items; |
8 |
use C4::Items; |
9 |
use C4::Context; |
9 |
use C4::Context; |
10 |
use Data::Dumper; |
10 |
|
11 |
use Test::More tests => 13; |
11 |
use Test::More tests => 14; |
12 |
|
12 |
|
13 |
BEGIN { |
13 |
BEGIN { |
14 |
use_ok('C4::Circulation'); |
14 |
use_ok('C4::Circulation'); |
Lines 215-235
my $borrower_id1 = C4::Members::AddMember(
Link Here
|
215 |
); |
215 |
); |
216 |
my $borrower_1 = C4::Members::GetMember(borrowernumber => $borrower_id1); |
216 |
my $borrower_1 = C4::Members::GetMember(borrowernumber => $borrower_id1); |
217 |
|
217 |
|
218 |
$query = |
218 |
is_deeply( |
219 |
"INSERT INTO branch_borrower_circ_rules (branchcode,categorycode,maxissueqty) VALUES( ?,?,?)"; |
219 |
GetBranchBorrowerCircRule(), |
|
|
220 |
{ maxissueqty => undef, maxonsiteissueqty => undef }, |
221 |
"Without parameter, GetBranchBorrower returns undef (unilimited) for maxissueqty and maxonsiteissueqty if no rules defined" |
222 |
); |
223 |
|
224 |
$query = q| |
225 |
INSERT INTO branch_borrower_circ_rules |
226 |
(branchcode, categorycode, maxissueqty, maxonsiteissueqty) |
227 |
VALUES( ?, ?, ?, ? ) |
228 |
|; |
229 |
|
220 |
$dbh->do( |
230 |
$dbh->do( |
221 |
$query, {}, |
231 |
$query, {}, |
222 |
$samplebranch1->{branchcode}, |
232 |
$samplebranch1->{branchcode}, |
223 |
$samplecat->{categorycode}, 5 |
233 |
$samplecat->{categorycode}, 5, 6 |
224 |
); |
234 |
); |
225 |
|
235 |
|
226 |
$query = |
236 |
$query = q| |
227 |
"INSERT INTO default_circ_rules (singleton,maxissueqty,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
237 |
INSERT INTO default_branch_circ_rules |
228 |
$dbh->do( $query, {}, 'singleton', 4, 3, 'homebranch' ); |
238 |
(branchcode, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
229 |
|
239 |
VALUES( ?, ?, ?, ?, ? ) |
230 |
$query = |
240 |
|; |
231 |
"INSERT INTO default_branch_circ_rules (branchcode,maxissueqty,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
241 |
$dbh->do( $query, {}, $samplebranch2->{branchcode}, |
232 |
$dbh->do( $query, {}, $samplebranch2->{branchcode}, 3, 1, 'holdingbranch' ); |
242 |
3, 2, 1, 'holdingbranch' ); |
|
|
243 |
$query = q| |
244 |
INSERT INTO default_circ_rules |
245 |
(singleton, maxissueqty, maxonsiteissueqty, holdallowed, returnbranch) |
246 |
VALUES( ?, ?, ?, ?, ? ) |
247 |
|; |
248 |
$dbh->do( $query, {}, 'singleton', 4, 5, 3, 'homebranch' ); |
233 |
|
249 |
|
234 |
$query = |
250 |
$query = |
235 |
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
251 |
"INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)"; |
Lines 253-278
$sth->execute(
Link Here
|
253 |
#Test GetBranchBorrowerCircRule |
269 |
#Test GetBranchBorrowerCircRule |
254 |
is_deeply( |
270 |
is_deeply( |
255 |
GetBranchBorrowerCircRule(), |
271 |
GetBranchBorrowerCircRule(), |
256 |
{ maxissueqty => 4 }, |
272 |
{ maxissueqty => 4, maxonsiteissueqty => 5 }, |
257 |
"Without parameter, GetBranchBorrower returns the maxissueqty of default_circ_rules" |
273 |
"Without parameter, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of default_circ_rules" |
258 |
); |
274 |
); |
259 |
is_deeply( |
275 |
is_deeply( |
260 |
GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ), |
276 |
GetBranchBorrowerCircRule( $samplebranch2->{branchcode} ), |
261 |
{ maxissueqty => 3 }, |
277 |
{ maxissueqty => 3, maxonsiteissueqty => 2 }, |
262 |
"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty corresponding" |
278 |
"Without only the branchcode specified, GetBranchBorrower returns the maxissueqty and maxonsiteissueqty corresponding" |
263 |
); |
279 |
); |
264 |
is_deeply( |
280 |
is_deeply( |
265 |
GetBranchBorrowerCircRule( |
281 |
GetBranchBorrowerCircRule( |
266 |
$samplebranch1->{branchcode}, |
282 |
$samplebranch1->{branchcode}, |
267 |
$samplecat->{categorycode} |
283 |
$samplecat->{categorycode} |
268 |
), |
284 |
), |
269 |
{ maxissueqty => 5 }, |
285 |
{ maxissueqty => 5, maxonsiteissueqty => 6 }, |
270 |
"GetBranchBorrower returns the maxissueqty of the branch1 and the category1" |
286 |
"GetBranchBorrower returns the maxissueqty and maxonsiteissueqty of the branch1 and the category1" |
271 |
); |
287 |
); |
272 |
is_deeply( |
288 |
is_deeply( |
273 |
GetBranchBorrowerCircRule( -1, -1 ), |
289 |
GetBranchBorrowerCircRule( -1, -1 ), |
274 |
{ maxissueqty => 4 }, |
290 |
{ maxissueqty => 4, maxonsiteissueqty => 5 }, |
275 |
"GetBranchBorrower with wrong parameters returns tthe maxissueqty of default_circ_rules" |
291 |
"GetBranchBorrower with wrong parameters returns the maxissueqty and maxonsiteissueqty of default_circ_rules" |
276 |
); |
292 |
); |
277 |
|
293 |
|
278 |
#Test GetBranchItemRule |
294 |
#Test GetBranchItemRule |