From 1af702d0879908aeaf8e9439f3978e0e75fc3372 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 17 Oct 2024 13:41:02 +0000 Subject: [PATCH] Bug 38204: Add unit test --- t/db_dependent/api/v1/acquisitions_baskets.t | 39 +++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/acquisitions_baskets.t b/t/db_dependent/api/v1/acquisitions_baskets.t index dd1edbb342d..69222a80b02 100755 --- a/t/db_dependent/api/v1/acquisitions_baskets.t +++ b/t/db_dependent/api/v1/acquisitions_baskets.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 2; use Test::Mojo; use t::lib::TestBuilder; @@ -70,3 +70,40 @@ subtest 'list_managers() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'list() tests' => sub { + + plan tests => 6; + + $schema->storage->txn_begin; + + $schema->resultset('Aqbasket')->search->delete; + + my $superlibrarian = + $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); + my $password = 'thePassword123'; + $superlibrarian->set_password( { password => $password, skip_validation => 1 } ); + my $userid = $superlibrarian->userid; + $superlibrarian->discard_changes; + + $t->get_ok("//$userid:$password@/api/v1/acquisitions/baskets")->status_is(200)->json_is( + [] + ); + + my $vendor = $builder->build_object( + { + class => 'Koha::Acquisition::Booksellers', + } + ); + my $basket = $builder->build_object( + { + class => 'Koha::Acquisition::Baskets', + value => { closedate => undef, authorisedby => undef, booksellerid => $vendor->id, branch => undef } + } + ); + + $t->get_ok("//$userid:$password@/api/v1/acquisitions/baskets")->status_is(200)->json_is( [$basket->to_api ]); + + $schema->storage->txn_rollback; + +} \ No newline at end of file -- 2.39.3 (Apple Git-146)