|
Lines 440-453
subtest 'to_api() tests' => sub {
Link Here
|
| 440 |
$schema->storage->txn_begin; |
440 |
$schema->storage->txn_begin; |
| 441 |
|
441 |
|
| 442 |
my $biblio = $builder->build_sample_biblio(); |
442 |
my $biblio = $builder->build_sample_biblio(); |
|
|
443 |
my $item = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
| 444 |
|
| 443 |
my $biblioitem_api = $biblio->biblioitem->to_api; |
445 |
my $biblioitem_api = $biblio->biblioitem->to_api; |
| 444 |
my $biblio_api = $biblio->to_api; |
446 |
my $biblio_api = $biblio->to_api; |
| 445 |
|
447 |
|
| 446 |
plan tests => scalar keys %{ $biblioitem_api }; |
448 |
plan tests => (scalar keys %{ $biblioitem_api }) + 1; |
| 447 |
|
449 |
|
| 448 |
foreach my $key ( keys %{ $biblioitem_api } ) { |
450 |
foreach my $key ( keys %{ $biblioitem_api } ) { |
| 449 |
is( $biblio_api->{$key}, $biblioitem_api->{$key}, "$key is added to the biblio object" ); |
451 |
is( $biblio_api->{$key}, $biblioitem_api->{$key}, "$key is added to the biblio object" ); |
| 450 |
} |
452 |
} |
| 451 |
|
453 |
|
|
|
454 |
$biblio_api = $biblio->to_api({ embed => { items => {} } }); |
| 455 |
is_deeply( $biblio_api->{items}, [ $item->to_api ], 'Item correctly embedded' ); |
| 456 |
|
| 452 |
$schema->storage->txn_rollback; |
457 |
$schema->storage->txn_rollback; |
| 453 |
}; |
458 |
}; |
| 454 |
- |
|
|