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 556-562
subtest 'Status Graph tests' => sub {
Link Here
|
556 |
|
564 |
|
557 |
subtest 'Backend testing (mocks)' => sub { |
565 |
subtest 'Backend testing (mocks)' => sub { |
558 |
|
566 |
|
559 |
plan tests => 13; |
567 |
plan tests => 16; |
560 |
|
568 |
|
561 |
$schema->storage->txn_begin; |
569 |
$schema->storage->txn_begin; |
562 |
|
570 |
|
Lines 564-570
subtest 'Backend testing (mocks)' => sub {
Link Here
|
564 |
# the Dummy plugin installed. load_backend & available_backends don't |
572 |
# the Dummy plugin installed. load_backend & available_backends don't |
565 |
# currently have tests as a result. |
573 |
# currently have tests as a result. |
566 |
|
574 |
|
567 |
t::lib::Mocks->mock_config('interlibrary_loans', { backend_dir => 'a_dir' } ); |
575 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
|
|
576 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
577 |
|
568 |
my $backend = Test::MockObject->new; |
578 |
my $backend = Test::MockObject->new; |
569 |
$backend->set_isa('Koha::Illbackends::Mock'); |
579 |
$backend->set_isa('Koha::Illbackends::Mock'); |
570 |
$backend->set_always('name', 'Mock'); |
580 |
$backend->set_always('name', 'Mock'); |
Lines 574-580
subtest 'Backend testing (mocks)' => sub {
Link Here
|
574 |
class => 'Koha::Illrequests', |
584 |
class => 'Koha::Illrequests', |
575 |
}); |
585 |
}); |
576 |
|
586 |
|
|
|
587 |
my $config = Test::MockObject->new; |
588 |
$config->set_always('partner_code', $categorycode); |
589 |
$config->set_always('backend_dir', 'a_dir'); |
590 |
|
577 |
$illrq->_backend($backend); |
591 |
$illrq->_backend($backend); |
|
|
592 |
$illrq->_config($config); |
578 |
|
593 |
|
579 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
594 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
580 |
"OK accessing mocked backend."); |
595 |
"OK accessing mocked backend."); |
Lines 621-626
subtest 'Backend testing (mocks)' => sub {
Link Here
|
621 |
"Test metadata." |
636 |
"Test metadata." |
622 |
); |
637 |
); |
623 |
|
638 |
|
|
|
639 |
$backend->mock( |
640 |
'capabilities', |
641 |
sub { |
642 |
my ($self, $name) = @_; |
643 |
if ($name eq 'get_requested_partners') { |
644 |
return sub { |
645 |
return 'me@nowhere.com; you@nowhere.com'; |
646 |
} |
647 |
} |
648 |
} |
649 |
); |
650 |
is($illrq->requested_partners, 'me@nowhere.com; you@nowhere.com', |
651 |
"requested_partners returns string by default"); |
652 |
|
653 |
Koha::Patron->new( |
654 |
{ |
655 |
surname => 'Test 1', |
656 |
email => 'me@nowhere.com', |
657 |
categorycode => $categorycode, |
658 |
branchcode => $branchcode |
659 |
} |
660 |
)->store(); |
661 |
|
662 |
Koha::Patron->new( |
663 |
{ |
664 |
surname => 'Test 2', |
665 |
email => 'you@nowhere.com', |
666 |
categorycode => $categorycode, |
667 |
branchcode => $branchcode |
668 |
} |
669 |
)->store(); |
670 |
|
671 |
my $part = $illrq->requested_partners(1); |
672 |
isa_ok($part, 'ARRAY', |
673 |
"requested_partners returns array when requested"); |
674 |
isa_ok(@{$part}[0], 'HASH', |
675 |
"requested_partners return array contains unblessed Koha patrons"); |
676 |
|
624 |
# capabilities: |
677 |
# capabilities: |
625 |
|
678 |
|
626 |
# No backend graph extension |
679 |
# No backend graph extension |
Lines 1559-1564
subtest 'Custom statuses' => sub {
Link Here
|
1559 |
is($ill_req->statusalias, undef, |
1612 |
is($ill_req->statusalias, undef, |
1560 |
"Koha::Illrequest->status overloading resetting status_alias"); |
1613 |
"Koha::Illrequest->status overloading resetting status_alias"); |
1561 |
|
1614 |
|
|
|
1615 |
$ill_req->status_alias($av->authorised_value); |
1616 |
is($ill_req->status_alias, $av->authorised_value, |
1617 |
"Koha::Illrequest->status_alias correctly handling string"); |
1618 |
|
1619 |
$ill_req->status_alias( |
1620 |
{ status => $av->authorised_value, additional => 'xyz' } |
1621 |
); |
1622 |
is($ill_req->status_alias, $av->authorised_value, |
1623 |
"Koha::Illrequest->status_alias correctly handling hashref"); |
1624 |
|
1562 |
$schema->storage->txn_rollback; |
1625 |
$schema->storage->txn_rollback; |
1563 |
}; |
1626 |
}; |
1564 |
|
1627 |
|
1565 |
- |
|
|