Bug 38204: Add unit test

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Matt Blenkinsop 2024-10-17 13:41:02 +00:00 committed by Katrin Fischer
parent 64d9579c47
commit 25fa03e485
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 38 additions and 1 deletions

View File

@ -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;
}