|
Lines 587-593
subtest 'to_api() tests' => sub {
Link Here
|
| 587 |
my $biblioitem_api = $biblio->biblioitem->to_api; |
587 |
my $biblioitem_api = $biblio->biblioitem->to_api; |
| 588 |
my $biblio_api = $biblio->to_api; |
588 |
my $biblio_api = $biblio->to_api; |
| 589 |
|
589 |
|
| 590 |
plan tests => ( scalar keys %{$biblioitem_api} ) + 1; |
590 |
plan tests => ( scalar keys %{$biblioitem_api} ) + 4; |
| 591 |
|
591 |
|
| 592 |
foreach my $key ( keys %{$biblioitem_api} ) { |
592 |
foreach my $key ( keys %{$biblioitem_api} ) { |
| 593 |
is( $biblio_api->{$key}, $biblioitem_api->{$key}, "$key is added to the biblio object" ); |
593 |
is( $biblio_api->{$key}, $biblioitem_api->{$key}, "$key is added to the biblio object" ); |
|
Lines 596-601
subtest 'to_api() tests' => sub {
Link Here
|
| 596 |
$biblio_api = $biblio->to_api( { embed => { items => {} } } ); |
596 |
$biblio_api = $biblio->to_api( { embed => { items => {} } } ); |
| 597 |
is_deeply( $biblio_api->{items}, [ $item->to_api ], 'Item correctly embedded' ); |
597 |
is_deeply( $biblio_api->{items}, [ $item->to_api ], 'Item correctly embedded' ); |
| 598 |
|
598 |
|
|
|
599 |
$biblio->biblioitem->delete(); |
| 600 |
throws_ok { $biblio->to_api } |
| 601 |
'Koha::Exceptions::RelatedObjectNotFound', |
| 602 |
'Exception thrown if the biblioitem accessor returns undef'; |
| 603 |
is( $@->class, 'Koha::Biblioitem' ); |
| 604 |
is( $@->accessor, 'biblioitem' ); |
| 605 |
|
| 599 |
$schema->storage->txn_rollback; |
606 |
$schema->storage->txn_rollback; |
| 600 |
}; |
607 |
}; |
| 601 |
|
608 |
|