|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 5; |
22 |
use Test::More tests => 6; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
|
24 |
|
| 25 |
use C4::Items; |
25 |
use C4::Items; |
|
Lines 36-41
use t::lib::Mocks;
Link Here
|
| 36 |
my $schema = Koha::Database->new->schema; |
36 |
my $schema = Koha::Database->new->schema; |
| 37 |
$schema->storage->txn_begin; |
37 |
$schema->storage->txn_begin; |
| 38 |
|
38 |
|
|
|
39 |
my $dbh = C4::Context->dbh; |
| 40 |
|
| 39 |
my $builder = t::lib::TestBuilder->new; |
41 |
my $builder = t::lib::TestBuilder->new; |
| 40 |
my $patron = $builder->build( { source => 'Borrower' } ); |
42 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 41 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
43 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
|
Lines 187-189
subtest 'can_be_transferred' => sub {
Link Here
|
| 187 |
}; |
189 |
}; |
| 188 |
|
190 |
|
| 189 |
$schema->storage->txn_rollback; |
191 |
$schema->storage->txn_rollback; |
|
|
192 |
|
| 193 |
|
| 194 |
subtest 'pickup_locations' => sub { |
| 195 |
plan tests => 25; |
| 196 |
|
| 197 |
$schema->storage->txn_begin; |
| 198 |
|
| 199 |
# Cleanup database |
| 200 |
Koha::Holds->search->delete; |
| 201 |
Koha::Patrons->search->delete; |
| 202 |
Koha::Items->search->delete; |
| 203 |
Koha::Libraries->search->delete; |
| 204 |
$dbh->do('DELETE FROM issues'); |
| 205 |
$dbh->do('DELETE FROM issuingrules'); |
| 206 |
$dbh->do( |
| 207 |
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed) |
| 208 |
VALUES (?, ?, ?, ?)}, |
| 209 |
{}, |
| 210 |
'*', '*', '*', 25 |
| 211 |
); |
| 212 |
$dbh->do('DELETE FROM branch_item_rules'); |
| 213 |
$dbh->do('DELETE FROM default_branch_circ_rules'); |
| 214 |
$dbh->do('DELETE FROM default_branch_item_rules'); |
| 215 |
$dbh->do('DELETE FROM default_circ_rules'); |
| 216 |
|
| 217 |
my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); |
| 218 |
my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); |
| 219 |
my $root3 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_hold_group => 1 } } ); |
| 220 |
|
| 221 |
my $library1 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
| 222 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
| 223 |
my $library3 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } ); |
| 224 |
my $library4 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
| 225 |
my $library5 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
| 226 |
my $library6 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); |
| 227 |
|
| 228 |
my $group1_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } ); |
| 229 |
my $group1_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } ); |
| 230 |
|
| 231 |
my $group2_3 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } ); |
| 232 |
my $group2_4 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } ); |
| 233 |
|
| 234 |
my $group3_5 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library5->branchcode } } ); |
| 235 |
my $group3_6 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root3->id, branchcode => $library6->branchcode } } ); |
| 236 |
|
| 237 |
my $biblio1 = $builder->build_object( { class => 'Koha::Biblios' } ); |
| 238 |
my $biblioitem1 = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio1->biblionumber } } ); |
| 239 |
my $biblio2 = $builder->build_object( { class => 'Koha::Biblios' } ); |
| 240 |
my $biblioitem2 = $builder->build_object( { class => 'Koha::Biblioitems', value => { biblionumber => $biblio2->biblionumber } } ); |
| 241 |
|
| 242 |
my $item1_1 = Koha::Item->new({ |
| 243 |
biblionumber => $biblio1->biblionumber, |
| 244 |
biblioitemnumber => $biblioitem1->biblioitemnumber, |
| 245 |
homebranch => $library1->branchcode, |
| 246 |
holdingbranch => $library2->branchcode, |
| 247 |
itype => 'test', |
| 248 |
barcode => "item11barcode", |
| 249 |
})->store; |
| 250 |
|
| 251 |
my $item1_3 = Koha::Item->new({ |
| 252 |
biblionumber => $biblio1->biblionumber, |
| 253 |
biblioitemnumber => $biblioitem1->biblioitemnumber, |
| 254 |
homebranch => $library3->branchcode, |
| 255 |
holdingbranch => $library4->branchcode, |
| 256 |
itype => 'test', |
| 257 |
barcode => "item13barcode", |
| 258 |
})->store; |
| 259 |
|
| 260 |
my $item2_2 = Koha::Item->new({ |
| 261 |
biblionumber => $biblio2->biblionumber, |
| 262 |
biblioitemnumber => $biblioitem2->biblioitemnumber, |
| 263 |
homebranch => $library2->branchcode, |
| 264 |
holdingbranch => $library1->branchcode, |
| 265 |
itype => 'test', |
| 266 |
barcode => "item22barcode", |
| 267 |
})->store; |
| 268 |
|
| 269 |
my $item2_3 = Koha::Item->new({ |
| 270 |
biblionumber => $biblio2->biblionumber, |
| 271 |
biblioitemnumber => $biblioitem2->biblioitemnumber, |
| 272 |
homebranch => $library3->branchcode, |
| 273 |
holdingbranch => $library3->branchcode, |
| 274 |
itype => 'test', |
| 275 |
barcode => "item23barcode", |
| 276 |
})->store; |
| 277 |
|
| 278 |
my $item2_4 = Koha::Item->new({ |
| 279 |
biblionumber => $biblio2->biblionumber, |
| 280 |
biblioitemnumber => $biblioitem2->biblioitemnumber, |
| 281 |
homebranch => $library4->branchcode, |
| 282 |
holdingbranch => $library4->branchcode, |
| 283 |
itype => 'test', |
| 284 |
barcode => "item24barcode", |
| 285 |
})->store; |
| 286 |
|
| 287 |
my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode } } ); |
| 288 |
my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode } } ); |
| 289 |
|
| 290 |
t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch'); |
| 291 |
|
| 292 |
#Case 1: holdallowed any, hold_fulfillment_policy any |
| 293 |
$dbh->do( |
| 294 |
q{INSERT INTO default_circ_rules (holdallowed, hold_fulfillment_policy, returnbranch) |
| 295 |
VALUES (?,?,?)}, |
| 296 |
{}, |
| 297 |
2, 'any', 'any' |
| 298 |
); |
| 299 |
|
| 300 |
my @pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 301 |
my @pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 302 |
my @pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 303 |
my @pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 304 |
|
| 305 |
|
| 306 |
ok(scalar(@pl_1_1) == 5 && scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5 && scalar(@pl_2_4) == 5, 'Returns all libraries that are pickup locations'); |
| 307 |
|
| 308 |
#Case 2: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'homebranch' |
| 309 |
$dbh->do( |
| 310 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 311 |
{}, |
| 312 |
1, 'any' |
| 313 |
); |
| 314 |
|
| 315 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 316 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 317 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 318 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 319 |
|
| 320 |
ok(scalar(@pl_1_1) == 5 && scalar(@pl_2_4) == 5, 'Returns all libraries that are pickup locations, when item\'s hombebranch equals patron\' homebranch'); |
| 321 |
ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'Returns no pickup locations'); |
| 322 |
|
| 323 |
#Case 3: holdallowed holdgroup, hold_fulfillment_policy any |
| 324 |
$dbh->do( |
| 325 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 326 |
{}, |
| 327 |
3, 'any' |
| 328 |
); |
| 329 |
|
| 330 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 331 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 332 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 333 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 334 |
|
| 335 |
ok(scalar(@pl_1_1) == 5 && scalar(@pl_2_4) == 5 && scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5, 'Returns all libraries that are pickup_locations, when item\'s hombebranch is in patron\' holdgroup'); |
| 336 |
|
| 337 |
#Case 4: holdallowed any, hold_fulfillment_policy holdgroup |
| 338 |
$dbh->do( |
| 339 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 340 |
{}, |
| 341 |
2, 'holdgroup' |
| 342 |
); |
| 343 |
|
| 344 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 345 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 346 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 347 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 348 |
|
| 349 |
ok(scalar(@pl_1_1) == 3 && scalar(@pl_2_4) == 3 && scalar(@pl_1_4) == 3 && scalar(@pl_2_1) == 3, 'Returns libraries in item\'s holdgroup, and that are pickup_locations'); |
| 350 |
|
| 351 |
#Case 5: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'homebranch' |
| 352 |
$dbh->do( |
| 353 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 354 |
{}, |
| 355 |
1, 'holdgroup' |
| 356 |
); |
| 357 |
|
| 358 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 359 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 360 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 361 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 362 |
|
| 363 |
ok(scalar(@pl_1_1) == 2 && scalar(@pl_2_4) == 1, 'Returns libraries in item\'s holdgroup whose homebranch equals patron\'s homebranch, and that are pickup_locations'); |
| 364 |
ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'Returns no pickup locations'); |
| 365 |
|
| 366 |
#Case 6: holdallowed holdgroup, hold_fulfillment_policy holdgroup |
| 367 |
$dbh->do( |
| 368 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 369 |
{}, |
| 370 |
3, 'holdgroup' |
| 371 |
); |
| 372 |
|
| 373 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 374 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 375 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 376 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 377 |
|
| 378 |
ok(scalar(@pl_1_1) == 2 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 1 && scalar(@pl_1_4) == 1, 'Returns libraries in item\'s holdgroup whose homebranch is included patron\'s holdgroup, and that are pickup_locations'); |
| 379 |
|
| 380 |
#Case 7: holdallowed any, hold_fulfillment_policy homebranch |
| 381 |
$dbh->do( |
| 382 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 383 |
{}, |
| 384 |
2, 'homebranch' |
| 385 |
); |
| 386 |
|
| 387 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 388 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 389 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 390 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 391 |
|
| 392 |
ok(scalar(@pl_1_1) == 1 && scalar(@pl_1_4) == 1 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 2, 'Returns homebranch of items in biblio, that are pickup_locations'); |
| 393 |
|
| 394 |
#Case 8: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'homebranch' |
| 395 |
$dbh->do( |
| 396 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 397 |
{}, |
| 398 |
1, 'homebranch' |
| 399 |
); |
| 400 |
|
| 401 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 402 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 403 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 404 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 405 |
|
| 406 |
ok(scalar(@pl_1_1) == 1 && scalar(@pl_2_4) == 1 && $pl_1_1[0]->{branchcode} eq $library1->branchcode && $pl_2_4[0]->{branchcode} eq $library4->branchcode, 'Returns homebranch of items in biblio that equals patron\'s homebranch, and that are pickup_locations'); |
| 407 |
ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'No pickup locations returned'); |
| 408 |
|
| 409 |
#Case 9: holdallowed holdgroup, hold_fulfillment_policy homebranch |
| 410 |
$dbh->do( |
| 411 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 412 |
{}, |
| 413 |
3, 'homebranch' |
| 414 |
); |
| 415 |
|
| 416 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 417 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 418 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 419 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 420 |
|
| 421 |
ok(scalar(@pl_1_1) == 1 && scalar(@pl_2_1) == 1 && scalar(@pl_2_4) == 1, 'Returns homebranch of items in biblio that are within patron\'s holdgroup, and that are pickup_locations'); |
| 422 |
ok(scalar(@pl_1_4) == 0, 'No pickup locations returned'); |
| 423 |
|
| 424 |
#Case 10: holdallowed any, hold_fulfillment_policy holdingbranch |
| 425 |
$dbh->do( |
| 426 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 427 |
{}, |
| 428 |
2, 'holdingbranch' |
| 429 |
); |
| 430 |
|
| 431 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 432 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 433 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 434 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 435 |
|
| 436 |
ok(scalar(@pl_1_1) == 2 && scalar(@pl_1_4) == 2 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 2, 'Returns holdingbranch of items in biblio, that are pickup_locations'); |
| 437 |
|
| 438 |
#Case 11: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'homebranch' |
| 439 |
$dbh->do( |
| 440 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 441 |
{}, |
| 442 |
1, 'holdingbranch' |
| 443 |
); |
| 444 |
|
| 445 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 446 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 447 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 448 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 449 |
|
| 450 |
ok(scalar(@pl_1_1) == 1 && scalar(@pl_2_4) == 1, 'Returns holdingbranch of items in biblio, whose homebranch equals patron\'s, and that are pickup_locations'); |
| 451 |
ok(scalar(@pl_1_4) == 0 && scalar(@pl_2_1) == 0, 'No pickup locations returned'); |
| 452 |
|
| 453 |
#Case 12: holdallowed holdgroup, hold_fulfillment_policy holdingbranch |
| 454 |
$dbh->do( |
| 455 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 456 |
{}, |
| 457 |
3, 'holdingbranch' |
| 458 |
); |
| 459 |
|
| 460 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 461 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 462 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 463 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 464 |
|
| 465 |
ok(scalar(@pl_1_1) == 1 && scalar(@pl_2_4) == 1 && scalar(@pl_1_4) == 1 && scalar(@pl_2_1) == 1, 'Returns holdingbranch of items in biblio, whose homebranch are within patron\'s holdgroup, and that are pickup_locations'); |
| 466 |
|
| 467 |
t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch'); |
| 468 |
|
| 469 |
#Case 13: holdallowed homebranch, hold_fulfillment_policy any, HomeOrHoldingBranch 'holdingbranch' |
| 470 |
$dbh->do( |
| 471 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 472 |
{}, |
| 473 |
1, 'any' |
| 474 |
); |
| 475 |
|
| 476 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 477 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 478 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 479 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 480 |
|
| 481 |
ok(scalar(@pl_1_4) == 5 && scalar(@pl_2_1) == 5 && scalar(@pl_2_4) == 5, 'Returns all libraries when item\'s holdingbranch equals patron\'s homebranch, and that are pickup_locations'); |
| 482 |
ok(scalar(@pl_1_1) == 0, 'No pickup locations returned'); |
| 483 |
|
| 484 |
#Case 14: holdallowed homebranch, hold_fulfillment_policy holdgroup, HomeOrHoldingBranch 'holdingbranch' |
| 485 |
$dbh->do( |
| 486 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 487 |
{}, |
| 488 |
1, 'holdgroup' |
| 489 |
); |
| 490 |
|
| 491 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 492 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 493 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 494 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 495 |
|
| 496 |
ok(scalar(@pl_1_4) == 1 && scalar(@pl_2_1) == 2 && scalar(@pl_2_4) == 1, 'Returns libraries in item\'s holdgroup whose holdingbranch equals patron\'s homebranch, and that are pickup_locations'); |
| 497 |
ok(scalar(@pl_1_1) == 0, 'No pickup locations returned'); |
| 498 |
|
| 499 |
#Case 15: holdallowed homebranch, hold_fulfillment_policy homebranch, HomeOrHoldingBranch 'holdingbranch' |
| 500 |
$dbh->do( |
| 501 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 502 |
{}, |
| 503 |
1, 'homebranch' |
| 504 |
); |
| 505 |
|
| 506 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 507 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 508 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 509 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 510 |
|
| 511 |
#ok(scalar(@pl_2_4) == 1 && $pl_2_4[0]->{branchcode} eq $library4->branchcode, 'Pickup location for patron 4 and item 3 renders item\'s holding branch'); |
| 512 |
ok(scalar(@pl_2_1) == 1 && scalar(@pl_2_4) == 1, 'Returns homebranch of items in biblio whose holdingbranch equals patron\'s homebranch, and that are pickup_locations'); |
| 513 |
ok(scalar(@pl_1_1) == 0 && scalar(@pl_1_4) == 0, 'No pickup locations returned'); |
| 514 |
|
| 515 |
#Case 16: holdallowed homebranch, hold_fulfillment_policy holdingbranch, HomeOrHoldingBranch 'holdingbranch' |
| 516 |
$dbh->do( |
| 517 |
q{UPDATE default_circ_rules set holdallowed = ?, hold_fulfillment_policy = ?}, |
| 518 |
{}, |
| 519 |
1, 'holdingbranch' |
| 520 |
); |
| 521 |
|
| 522 |
@pl_1_1 = $biblio1->pickup_locations( { patron => $patron1 } ); |
| 523 |
@pl_1_4 = $biblio1->pickup_locations( { patron => $patron4 } ); |
| 524 |
@pl_2_1 = $biblio2->pickup_locations( { patron => $patron1 } ); |
| 525 |
@pl_2_4 = $biblio2->pickup_locations( { patron => $patron4 } ); |
| 526 |
|
| 527 |
ok(scalar(@pl_1_4) == 1 && scalar(@pl_2_1) == 1 && scalar(@pl_2_4) == 1, 'Returns holdingbranch of items in biblio that equals patron\'s homebranch, and that are pickup_locations'); |
| 528 |
ok(scalar(@pl_1_1) == 0, 'No pickup locations returned'); |
| 529 |
|
| 530 |
$schema->storage->txn_rollback; |
| 531 |
}; |