Bugzilla – Attachment 159879 Details for
Bug 35574
Bookings page should require only manage_bookings permissions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35574: Add unit tests for api change
Bug-35574-Add-unit-tests-for-api-change.patch (text/plain), 3.51 KB, created by
Martin Renvoize
on 2023-12-15 11:07:58 UTC
(
hide
)
Description:
Bug 35574: Add unit tests for api change
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2023-12-15 11:07:58 UTC
Size:
3.51 KB
patch
obsolete
>From d560db8d28eb38cd6e254d461f59100291a985a4 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 15 Dec 2023 11:05:42 +0000 >Subject: [PATCH] Bug 35574: Add unit tests for api change > >We add the corresponding unit tests for the biblio/bookings endpoint to >ensure no regressions in the future. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/api/v1/biblios.t | 73 ++++++++++++++++++++++++++++++++- > 1 file changed, 72 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index cb4f02bb1e7..f73fc31da5e 100755 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -20,7 +20,7 @@ use Modern::Perl; > use utf8; > use Encode; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use Test::MockModule; > use Test::Mojo; > use Test::Warn; >@@ -35,6 +35,7 @@ use C4::Circulation qw( AddIssue AddReturn ); > > use Koha::Biblios; > use Koha::Database; >+use Koha::DateUtils qw (dt_from_string); > use Koha::Checkouts; > use Koha::Old::Checkouts; > >@@ -656,6 +657,76 @@ subtest 'get_items_public() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'get_bookings() tests' => sub { >+ >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } # no additional permissions >+ } >+ ); >+ $builder->build( >+ { >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $librarian->borrowernumber, >+ module_bit => 1, >+ code => 'manage_bookings', >+ }, >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } >+ } >+ ); >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $unauth_userid = $patron->userid; >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item1 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); >+ my $item2 = $builder->build_sample_item( { bookable => 1, biblionumber => $biblio->id } ); >+ >+ $t->get_ok("//$unauth_userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/bookings") >+ ->status_is(403); >+ >+ $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/bookings") >+ ->status_is(200) >+ ->json_is( '' => [], 'No bookings on the biblio' ); >+ >+ # One booking >+ my $start_0 = dt_from_string->subtract( days => 2 )->truncate( to => 'day' ); >+ my $end_0 = dt_from_string->add( days => 4 )->truncate( to => 'day' ); >+ my $booking_0 = $builder->build_object( >+ { >+ class => 'Koha::Bookings', >+ value => { >+ biblio_id => $biblio->id, >+ item_id => $item1->id, >+ start_date => $start_0, >+ end_date => $end_0 >+ } >+ } >+ ); >+ >+ my $ret = $t->get_ok( "//$userid:$password@/api/v1/biblios/" . $biblio->biblionumber . "/bookings") >+ ->status_is(200) >+ ->tx->res->json; >+ >+ is_deeply( $ret, [ $booking_0->to_api ] ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'get_checkouts() tests' => sub { > > plan tests => 14; >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35574
:
159851
|
159852
|
159853
|
159874
|
159875
|
159876
|
159877
|
159878
|
159879
|
159880
|
159886
|
159887
|
159888
|
159889
|
159890
|
159896
|
159897
|
159898
|
159899
|
159900