|
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 373-379
subtest 'Status Graph tests' => sub {
Link Here
|
| 373 |
|
381 |
|
| 374 |
subtest 'Backend testing (mocks)' => sub { |
382 |
subtest 'Backend testing (mocks)' => sub { |
| 375 |
|
383 |
|
| 376 |
plan tests => 13; |
384 |
plan tests => 16; |
| 377 |
|
385 |
|
| 378 |
$schema->storage->txn_begin; |
386 |
$schema->storage->txn_begin; |
| 379 |
|
387 |
|
|
Lines 381-387
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 381 |
# the Dummy plugin installed. load_backend & available_backends don't |
389 |
# the Dummy plugin installed. load_backend & available_backends don't |
| 382 |
# currently have tests as a result. |
390 |
# currently have tests as a result. |
| 383 |
|
391 |
|
| 384 |
t::lib::Mocks->mock_config('interlibrary_loans', { backend_dir => 'a_dir' } ); |
392 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
|
|
393 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 394 |
|
| 385 |
my $backend = Test::MockObject->new; |
395 |
my $backend = Test::MockObject->new; |
| 386 |
$backend->set_isa('Koha::Illbackends::Mock'); |
396 |
$backend->set_isa('Koha::Illbackends::Mock'); |
| 387 |
$backend->set_always('name', 'Mock'); |
397 |
$backend->set_always('name', 'Mock'); |
|
Lines 391-397
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 391 |
class => 'Koha::Illrequests', |
401 |
class => 'Koha::Illrequests', |
| 392 |
}); |
402 |
}); |
| 393 |
|
403 |
|
|
|
404 |
my $config = Test::MockObject->new; |
| 405 |
$config->set_always('partner_code', $categorycode); |
| 406 |
$config->set_always('backend_dir', 'a_dir'); |
| 407 |
|
| 394 |
$illrq->_backend($backend); |
408 |
$illrq->_backend($backend); |
|
|
409 |
$illrq->_config($config); |
| 395 |
|
410 |
|
| 396 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
411 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
| 397 |
"OK accessing mocked backend."); |
412 |
"OK accessing mocked backend."); |
|
Lines 438-443
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 438 |
"Test metadata." |
453 |
"Test metadata." |
| 439 |
); |
454 |
); |
| 440 |
|
455 |
|
|
|
456 |
$backend->mock( |
| 457 |
'capabilities', |
| 458 |
sub { |
| 459 |
my ($self, $name) = @_; |
| 460 |
if ($name eq 'get_requested_partners') { |
| 461 |
return sub { |
| 462 |
return 'me@nowhere.com; you@nowhere.com'; |
| 463 |
} |
| 464 |
} |
| 465 |
} |
| 466 |
); |
| 467 |
is($illrq->requested_partners, 'me@nowhere.com; you@nowhere.com', |
| 468 |
"requested_partners returns string by default"); |
| 469 |
|
| 470 |
Koha::Patron->new( |
| 471 |
{ |
| 472 |
surname => 'Test 1', |
| 473 |
email => 'me@nowhere.com', |
| 474 |
categorycode => $categorycode, |
| 475 |
branchcode => $branchcode |
| 476 |
} |
| 477 |
)->store(); |
| 478 |
|
| 479 |
Koha::Patron->new( |
| 480 |
{ |
| 481 |
surname => 'Test 2', |
| 482 |
email => 'you@nowhere.com', |
| 483 |
categorycode => $categorycode, |
| 484 |
branchcode => $branchcode |
| 485 |
} |
| 486 |
)->store(); |
| 487 |
|
| 488 |
my $part = $illrq->requested_partners(1); |
| 489 |
isa_ok($part, 'ARRAY', |
| 490 |
"requested_partners returns array when requested"); |
| 491 |
isa_ok(@{$part}[0], 'HASH', |
| 492 |
"requested_partners return array contains unblessed Koha patrons"); |
| 493 |
|
| 441 |
# capabilities: |
494 |
# capabilities: |
| 442 |
|
495 |
|
| 443 |
# No backend graph extension |
496 |
# No backend graph extension |
|
Lines 1270-1275
subtest 'Custom statuses' => sub {
Link Here
|
| 1270 |
is($ill_req->statusalias, undef, |
1323 |
is($ill_req->statusalias, undef, |
| 1271 |
"Koha::Illrequest->status overloading resetting status_alias"); |
1324 |
"Koha::Illrequest->status overloading resetting status_alias"); |
| 1272 |
|
1325 |
|
|
|
1326 |
$ill_req->status_alias($av->authorised_value); |
| 1327 |
is($ill_req->status_alias, $av->authorised_value, |
| 1328 |
"Koha::Illrequest->status_alias correctly handling string"); |
| 1329 |
|
| 1330 |
$ill_req->status_alias( |
| 1331 |
{ status => $av->authorised_value, additional => 'xyz' } |
| 1332 |
); |
| 1333 |
is($ill_req->status_alias, $av->authorised_value, |
| 1334 |
"Koha::Illrequest->status_alias correctly handling hashref"); |
| 1335 |
|
| 1273 |
$schema->storage->txn_rollback; |
1336 |
$schema->storage->txn_rollback; |
| 1274 |
}; |
1337 |
}; |
| 1275 |
|
1338 |
|
| 1276 |
- |
|
|