|
Lines 50-56
use_ok('Koha::Illrequests');
Link Here
|
| 50 |
|
50 |
|
| 51 |
subtest 'Basic object tests' => sub { |
51 |
subtest 'Basic object tests' => sub { |
| 52 |
|
52 |
|
| 53 |
plan tests => 24; |
53 |
plan tests => 26; |
| 54 |
|
54 |
|
| 55 |
$schema->storage->txn_begin; |
55 |
$schema->storage->txn_begin; |
| 56 |
|
56 |
|
|
Lines 122-127
subtest 'Basic object tests' => sub {
Link Here
|
| 122 |
is(Koha::Illrequests->search->count, 0, |
122 |
is(Koha::Illrequests->search->count, 0, |
| 123 |
"No illrequest found after delete."); |
123 |
"No illrequest found after delete."); |
| 124 |
|
124 |
|
|
|
125 |
$illrq_obj->status('REQ'); |
| 126 |
is($illrq_obj->status, 'REQ', |
| 127 |
"status correctly handles strings"); |
| 128 |
|
| 129 |
$illrq_obj->status({ status => 'NEW', additional => 'add'}); |
| 130 |
is($illrq_obj->status, 'NEW', |
| 131 |
"status correctly handles hashrefs"); |
| 132 |
|
| 125 |
$schema->storage->txn_rollback; |
133 |
$schema->storage->txn_rollback; |
| 126 |
}; |
134 |
}; |
| 127 |
|
135 |
|
|
Lines 492-498
subtest 'Status Graph tests' => sub {
Link Here
|
| 492 |
|
500 |
|
| 493 |
subtest 'Backend testing (mocks)' => sub { |
501 |
subtest 'Backend testing (mocks)' => sub { |
| 494 |
|
502 |
|
| 495 |
plan tests => 13; |
503 |
plan tests => 16; |
| 496 |
|
504 |
|
| 497 |
$schema->storage->txn_begin; |
505 |
$schema->storage->txn_begin; |
| 498 |
|
506 |
|
|
Lines 500-506
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 500 |
# the Dummy plugin installed. load_backend & available_backends don't |
508 |
# the Dummy plugin installed. load_backend & available_backends don't |
| 501 |
# currently have tests as a result. |
509 |
# currently have tests as a result. |
| 502 |
|
510 |
|
| 503 |
t::lib::Mocks->mock_config('interlibrary_loans', { backend_dir => 'a_dir' } ); |
511 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
|
|
512 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 513 |
|
| 504 |
my $backend = Test::MockObject->new; |
514 |
my $backend = Test::MockObject->new; |
| 505 |
$backend->set_isa('Koha::Illbackends::Mock'); |
515 |
$backend->set_isa('Koha::Illbackends::Mock'); |
| 506 |
$backend->set_always('name', 'Mock'); |
516 |
$backend->set_always('name', 'Mock'); |
|
Lines 510-516
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 510 |
class => 'Koha::Illrequests', |
520 |
class => 'Koha::Illrequests', |
| 511 |
}); |
521 |
}); |
| 512 |
|
522 |
|
|
|
523 |
my $config = Test::MockObject->new; |
| 524 |
$config->set_always('partner_code', $categorycode); |
| 525 |
$config->set_always('backend_dir', 'a_dir'); |
| 526 |
|
| 513 |
$illrq->_backend($backend); |
527 |
$illrq->_backend($backend); |
|
|
528 |
$illrq->_config($config); |
| 514 |
|
529 |
|
| 515 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
530 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
| 516 |
"OK accessing mocked backend."); |
531 |
"OK accessing mocked backend."); |
|
Lines 557-562
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 557 |
"Test metadata." |
572 |
"Test metadata." |
| 558 |
); |
573 |
); |
| 559 |
|
574 |
|
|
|
575 |
$backend->mock( |
| 576 |
'capabilities', |
| 577 |
sub { |
| 578 |
my ($self, $name) = @_; |
| 579 |
if ($name eq 'get_requested_partners') { |
| 580 |
return sub { |
| 581 |
return 'me@nowhere.com; you@nowhere.com'; |
| 582 |
} |
| 583 |
} |
| 584 |
} |
| 585 |
); |
| 586 |
is($illrq->requested_partners, 'me@nowhere.com; you@nowhere.com', |
| 587 |
"requested_partners returns string by default"); |
| 588 |
|
| 589 |
Koha::Patron->new( |
| 590 |
{ |
| 591 |
surname => 'Test 1', |
| 592 |
email => 'me@nowhere.com', |
| 593 |
categorycode => $categorycode, |
| 594 |
branchcode => $branchcode |
| 595 |
} |
| 596 |
)->store(); |
| 597 |
|
| 598 |
Koha::Patron->new( |
| 599 |
{ |
| 600 |
surname => 'Test 2', |
| 601 |
email => 'you@nowhere.com', |
| 602 |
categorycode => $categorycode, |
| 603 |
branchcode => $branchcode |
| 604 |
} |
| 605 |
)->store(); |
| 606 |
|
| 607 |
my $part = $illrq->requested_partners(1); |
| 608 |
isa_ok($part, 'ARRAY', |
| 609 |
"requested_partners returns array when requested"); |
| 610 |
isa_ok(@{$part}[0], 'HASH', |
| 611 |
"requested_partners return array contains unblessed Koha patrons"); |
| 612 |
|
| 560 |
# capabilities: |
613 |
# capabilities: |
| 561 |
|
614 |
|
| 562 |
# No backend graph extension |
615 |
# No backend graph extension |
|
Lines 1395-1400
subtest 'Custom statuses' => sub {
Link Here
|
| 1395 |
is($ill_req->statusalias, undef, |
1448 |
is($ill_req->statusalias, undef, |
| 1396 |
"Koha::Illrequest->status overloading resetting status_alias"); |
1449 |
"Koha::Illrequest->status overloading resetting status_alias"); |
| 1397 |
|
1450 |
|
|
|
1451 |
$ill_req->status_alias($av->authorised_value); |
| 1452 |
is($ill_req->status_alias, $av->authorised_value, |
| 1453 |
"Koha::Illrequest->status_alias correctly handling string"); |
| 1454 |
|
| 1455 |
$ill_req->status_alias( |
| 1456 |
{ status => $av->authorised_value, additional => 'xyz' } |
| 1457 |
); |
| 1458 |
is($ill_req->status_alias, $av->authorised_value, |
| 1459 |
"Koha::Illrequest->status_alias correctly handling hashref"); |
| 1460 |
|
| 1398 |
$schema->storage->txn_rollback; |
1461 |
$schema->storage->txn_rollback; |
| 1399 |
}; |
1462 |
}; |
| 1400 |
|
1463 |
|
| 1401 |
- |
|
|