|
Lines 39-45
use_ok('Koha::Illrequests');
Link Here
|
| 39 |
|
39 |
|
| 40 |
subtest 'Basic object tests' => sub { |
40 |
subtest 'Basic object tests' => sub { |
| 41 |
|
41 |
|
| 42 |
plan tests => 24; |
42 |
plan tests => 26; |
| 43 |
|
43 |
|
| 44 |
$schema->storage->txn_begin; |
44 |
$schema->storage->txn_begin; |
| 45 |
|
45 |
|
|
Lines 111-116
subtest 'Basic object tests' => sub {
Link Here
|
| 111 |
is(Koha::Illrequests->search->count, 0, |
111 |
is(Koha::Illrequests->search->count, 0, |
| 112 |
"No illrequest found after delete."); |
112 |
"No illrequest found after delete."); |
| 113 |
|
113 |
|
|
|
114 |
$illrq_obj->status('REQ'); |
| 115 |
is($illrq_obj->status, 'REQ', |
| 116 |
"status correctly handles strings"); |
| 117 |
|
| 118 |
$illrq_obj->status({ status => 'NEW', additional => 'add'}); |
| 119 |
is($illrq_obj->status, 'NEW', |
| 120 |
"status correctly handles hashrefs"); |
| 121 |
|
| 114 |
$schema->storage->txn_rollback; |
122 |
$schema->storage->txn_rollback; |
| 115 |
}; |
123 |
}; |
| 116 |
|
124 |
|
|
Lines 231-237
subtest 'Status Graph tests' => sub {
Link Here
|
| 231 |
|
239 |
|
| 232 |
subtest 'Backend testing (mocks)' => sub { |
240 |
subtest 'Backend testing (mocks)' => sub { |
| 233 |
|
241 |
|
| 234 |
plan tests => 13; |
242 |
plan tests => 16; |
| 235 |
|
243 |
|
| 236 |
$schema->storage->txn_begin; |
244 |
$schema->storage->txn_begin; |
| 237 |
|
245 |
|
|
Lines 239-245
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 239 |
# the Dummy plugin installed. load_backend & available_backends don't |
247 |
# the Dummy plugin installed. load_backend & available_backends don't |
| 240 |
# currently have tests as a result. |
248 |
# currently have tests as a result. |
| 241 |
|
249 |
|
| 242 |
t::lib::Mocks->mock_config('interlibrary_loans', { backend_dir => 'a_dir' } ); |
250 |
my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; |
|
|
251 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 252 |
|
| 243 |
my $backend = Test::MockObject->new; |
253 |
my $backend = Test::MockObject->new; |
| 244 |
$backend->set_isa('Koha::Illbackends::Mock'); |
254 |
$backend->set_isa('Koha::Illbackends::Mock'); |
| 245 |
$backend->set_always('name', 'Mock'); |
255 |
$backend->set_always('name', 'Mock'); |
|
Lines 250-256
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 250 |
value => { borrowernumber => $patron->{borrowernumber} } |
260 |
value => { borrowernumber => $patron->{borrowernumber} } |
| 251 |
}); |
261 |
}); |
| 252 |
|
262 |
|
|
|
263 |
my $config = Test::MockObject->new; |
| 264 |
$config->set_always('partner_code', $categorycode); |
| 265 |
$config->set_always('backend_dir', 'a_dir'); |
| 266 |
|
| 253 |
$illrq->_backend($backend); |
267 |
$illrq->_backend($backend); |
|
|
268 |
$illrq->_config($config); |
| 254 |
|
269 |
|
| 255 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
270 |
isa_ok($illrq->_backend, 'Koha::Illbackends::Mock', |
| 256 |
"OK accessing mocked backend."); |
271 |
"OK accessing mocked backend."); |
|
Lines 297-302
subtest 'Backend testing (mocks)' => sub {
Link Here
|
| 297 |
"Test metadata." |
312 |
"Test metadata." |
| 298 |
); |
313 |
); |
| 299 |
|
314 |
|
|
|
315 |
$backend->mock( |
| 316 |
'capabilities', |
| 317 |
sub { |
| 318 |
my ($self, $name) = @_; |
| 319 |
if ($name eq 'get_requested_partners') { |
| 320 |
return sub { |
| 321 |
return 'me@nowhere.com; you@nowhere.com'; |
| 322 |
} |
| 323 |
} |
| 324 |
} |
| 325 |
); |
| 326 |
is($illrq->requested_partners, 'me@nowhere.com; you@nowhere.com', |
| 327 |
"requested_partners returns string by default"); |
| 328 |
|
| 329 |
Koha::Patron->new( |
| 330 |
{ |
| 331 |
surname => 'Test 1', |
| 332 |
email => 'me@nowhere.com', |
| 333 |
categorycode => $categorycode, |
| 334 |
branchcode => $branchcode |
| 335 |
} |
| 336 |
)->store(); |
| 337 |
|
| 338 |
Koha::Patron->new( |
| 339 |
{ |
| 340 |
surname => 'Test 2', |
| 341 |
email => 'you@nowhere.com', |
| 342 |
categorycode => $categorycode, |
| 343 |
branchcode => $branchcode |
| 344 |
} |
| 345 |
)->store(); |
| 346 |
|
| 347 |
my $part = $illrq->requested_partners(1); |
| 348 |
isa_ok($part, 'ARRAY', |
| 349 |
"requested_partners returns array when requested"); |
| 350 |
isa_ok(@{$part}[0], 'HASH', |
| 351 |
"requested_partners return array contains unblessed Koha patrons"); |
| 352 |
|
| 300 |
# capabilities: |
353 |
# capabilities: |
| 301 |
|
354 |
|
| 302 |
# No backend graph extension |
355 |
# No backend graph extension |
|
Lines 842-848
subtest 'Checking Limits' => sub {
Link Here
|
| 842 |
|
895 |
|
| 843 |
subtest 'Custom statuses' => sub { |
896 |
subtest 'Custom statuses' => sub { |
| 844 |
|
897 |
|
| 845 |
plan tests => 3; |
898 |
plan tests => 5; |
| 846 |
|
899 |
|
| 847 |
$schema->storage->txn_begin; |
900 |
$schema->storage->txn_begin; |
| 848 |
|
901 |
|
|
Lines 890-894
subtest 'Custom statuses' => sub {
Link Here
|
| 890 |
is($ill_req->statusalias, undef, |
943 |
is($ill_req->statusalias, undef, |
| 891 |
"Koha::Illrequest->status overloading resetting status_alias"); |
944 |
"Koha::Illrequest->status overloading resetting status_alias"); |
| 892 |
|
945 |
|
|
|
946 |
$ill_req->status_alias($av->authorised_value); |
| 947 |
is($ill_req->status_alias, $av->authorised_value, |
| 948 |
"Koha::Illrequest->status_alias correctly handling string"); |
| 949 |
|
| 950 |
$ill_req->status_alias( |
| 951 |
{ status => $av->authorised_value, additional => 'xyz' } |
| 952 |
); |
| 953 |
is($ill_req->status_alias, $av->authorised_value, |
| 954 |
"Koha::Illrequest->status_alias correctly handling hashref"); |
| 955 |
|
| 893 |
$schema->storage->txn_rollback; |
956 |
$schema->storage->txn_rollback; |
| 894 |
}; |
957 |
}; |
| 895 |
- |
|
|