View | Details | Raw Unified | Return to bug 35246
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Biblio.t (-1 / +8 lines)
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
(-)a/t/db_dependent/api/v1/biblios.t (-2 / +8 lines)
Lines 50-56 my $t = Test::Mojo->new('Koha::REST::V1'); Link Here
50
50
51
subtest 'get() tests' => sub {
51
subtest 'get() tests' => sub {
52
52
53
    plan tests => 22;
53
    plan tests => 26;
54
54
55
    $schema->storage->txn_begin;
55
    $schema->storage->txn_begin;
56
56
Lines 97-102 subtest 'get() tests' => sub { Link Here
97
    $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
97
    $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
98
        ->status_is(200)->content_is( $biblio->metadata->record->as_formatted );
98
        ->status_is(200)->content_is( $biblio->metadata->record->as_formatted );
99
99
100
    # Simulate a data error situation (BZ35246)
101
    $biblio->biblioitem->delete();
102
103
    $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'application/json' } )
104
        ->status_is(500)->json_is( '/error_code', 'internal_server_error' )
105
        ->json_is( '/error', 'Something went wrong, check Koha logs for details.' );
106
100
    $biblio->delete;
107
    $biblio->delete;
101
    $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } )
108
    $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } )
102
        ->status_is(404)->json_is( '/error', 'Bibliographic record not found' );
109
        ->status_is(404)->json_is( '/error', 'Bibliographic record not found' );
103
- 

Return to bug 35246