|
Lines 215-221
subtest 'TO_JSON tests' => sub {
Link Here
|
| 215 |
|
215 |
|
| 216 |
subtest "to_api() tests" => sub { |
216 |
subtest "to_api() tests" => sub { |
| 217 |
|
217 |
|
| 218 |
plan tests => 26; |
218 |
plan tests => 28; |
| 219 |
|
219 |
|
| 220 |
$schema->storage->txn_begin; |
220 |
$schema->storage->txn_begin; |
| 221 |
|
221 |
|
|
Lines 330-335
subtest "to_api() tests" => sub {
Link Here
|
| 330 |
"Exception message correct" |
330 |
"Exception message correct" |
| 331 |
); |
331 |
); |
| 332 |
|
332 |
|
|
|
333 |
|
| 334 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 335 |
$builder->build_object( |
| 336 |
{ |
| 337 |
class => 'Koha::Holds', |
| 338 |
value => { |
| 339 |
biblionumber => $biblio->biblionumber, |
| 340 |
borrowernumber => $patron->borrowernumber |
| 341 |
} |
| 342 |
} |
| 343 |
); |
| 344 |
$builder->build_object( |
| 345 |
{ |
| 346 |
class => 'Koha::Holds', |
| 347 |
value => { |
| 348 |
biblionumber => $biblio->biblionumber, |
| 349 |
borrowernumber => $patron->borrowernumber |
| 350 |
} |
| 351 |
} |
| 352 |
); |
| 353 |
|
| 354 |
my $patron_api = $patron->to_api( |
| 355 |
{ |
| 356 |
embed => { holds_count => { is_count => 1 } } |
| 357 |
} |
| 358 |
); |
| 359 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
| 360 |
|
| 361 |
throws_ok |
| 362 |
{ |
| 363 |
$patron->to_api({ embed => { holds_count => {} } }); |
| 364 |
} |
| 365 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
| 366 |
'Unknown method exception thrown if is_count not specified'; |
| 367 |
|
| 333 |
$schema->storage->txn_rollback; |
368 |
$schema->storage->txn_rollback; |
| 334 |
}; |
369 |
}; |
| 335 |
|
370 |
|
| 336 |
- |
|
|