From 5fbb0fa7d8e126339f9ba4dc3b98242f1b8f30c7 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 17 Apr 2024 10:34:49 +0000 Subject: [PATCH] Bug 36618: Add unit tests prove t/db_dependent/api/v1/erm_eholdings_titles.t --- t/db_dependent/api/v1/erm_eholdings_titles.t | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/api/v1/erm_eholdings_titles.t b/t/db_dependent/api/v1/erm_eholdings_titles.t index e2f12a62ad..2313c01418 100755 --- a/t/db_dependent/api/v1/erm_eholdings_titles.t +++ b/t/db_dependent/api/v1/erm_eholdings_titles.t @@ -192,7 +192,7 @@ subtest 'get() tests' => sub { subtest 'add() tests' => sub { - plan tests => 24; + plan tests => 25; $schema->storage->txn_begin; @@ -334,6 +334,22 @@ subtest 'add() tests' => sub { ] ); + subtest 'add eholdings title linked to biblio tests' => sub { + + plan tests => 4; + + delete $ehtitle->{title_id}; + my $request_body = { + %{$ehtitle}, + }; + $request_body->{create_linked_biblio} = 1; + my $biblios_count = Koha::Biblios->search()->count; + $t->post_ok( "//$userid:$password@/api/v1/erm/eholdings/local/titles/" => json => $request_body ) + ->status_is(201)->json_is( '/publication_title' => 'Publication title' ); + my $new_biblios_count = Koha::Biblios->search()->count; + is( $new_biblios_count, $biblios_count + 1, "Biblio was added" ); + }; + $schema->storage->txn_rollback; }; @@ -475,7 +491,7 @@ subtest 'update() tests' => sub { my $ehtitle_updated_title = { publication_title => "The journal of writing unit tests :" }; $t->put_ok( - "//$userid:$password@/api/v1/erm/eholdings/local/titles/$ehtitle_id" => json => $ehtitle_updated_title ) + "//$userid:$password@/api/v1/erm/eholdings/local/titles/$ehtitle_id" => json => { %$ehtitle_updated_title, create_linked_biblio => 1 } ) ->status_is(200)->json_is( '/publication_title' => 'The journal of writing unit tests :' ); $biblio->discard_changes; -- 2.37.1 (Apple Git-137.1)