From 706ef24262758116d6a9d30b15e0a4b97c1c6ba5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 15 Dec 2023 11:46:08 +0000 Subject: [PATCH] Bug 35469: Unit test This patch adds a unit test to check that manage_bookings allows fetching of checkouts. --- t/db_dependent/api/v1/checkouts.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t index 8c16f1f88e0..4b3437cd7d1 100755 --- a/t/db_dependent/api/v1/checkouts.t +++ b/t/db_dependent/api/v1/checkouts.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 105; +use Test::More tests => 108; use Test::MockModule; use Test::Mojo; use t::lib::Mocks; @@ -67,6 +67,29 @@ $t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$patron_id" ) my $notexisting_patron_id = $patron_id + 1; $t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$notexisting_patron_id" ) + ->status_is(200, 'manage_bookings allows checkouts access') + ->json_is([]); + +my $bookings_librarian = $builder->build_object( + { + class => 'Koha::Patrons', + value => { flags => 0 } # no additional permissions + } +); +$builder->build( + { + source => 'UserPermission', + value => { + borrowernumber => $bookings_librarian->borrowernumber, + module_bit => 1, + code => 'manage_bookings', + }, + } +); +$bookings_librarian->set_password( { password => $password, skip_validation => 1 } ); +my $bookings_userid = $bookings_librarian->userid; + +$t->get_ok( "//$bookings_userid:$password@/api/v1/checkouts?patron_id=$patron_id" ) ->status_is(200) ->json_is([]); -- 2.43.0