Bugzilla – Attachment 127757 Details for
Bug 29508
GET /patrons/:patron_id should use Koha::Patrons->search_limited
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29508: Regression tests
Bug-29508-Regression-tests.patch (text/plain), 3.08 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-11-17 19:45:14 UTC
(
hide
)
Description:
Bug 29508: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-11-17 19:45:14 UTC
Size:
3.08 KB
patch
obsolete
>From 38f7e8a8c9135fb8cfa6f480a52604e32a4aaa55 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 17 Nov 2021 16:35:33 -0300 >Subject: [PATCH] Bug 29508: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/patrons.t | 56 ++++++++++++++++++++++++++++++++- > 1 file changed, 55 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index 1201629ffd..2d14174b50 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -194,7 +194,8 @@ subtest 'list() tests' => sub { > }; > > subtest 'get() tests' => sub { >- plan tests => 2; >+ >+ plan tests => 3; > > $schema->storage->txn_begin; > unauthorized_access_tests('GET', -1, undef); >@@ -226,6 +227,59 @@ subtest 'get() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'search_limited() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_3 = $builder->build_object({ class => 'Koha::Libraries' }); >+ >+ my $patron_1 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_1->id } }); >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_2->id } }); >+ my $patron_3 = $builder->build_object({ class => 'Koha::Patrons', value => { branchcode => $library_3->id } }); >+ >+ my @libraries_where_can_see_patrons = ($library_1->id, $library_2->id); >+ >+ my $mocked_patron = Test::MockModule->new('Koha::Patron'); >+ $mocked_patron->mock( 'libraries_where_can_see_patrons', sub >+ { >+ return @libraries_where_can_see_patrons; >+ } >+ ); >+ >+ my $librarian = $builder->build_object( >+ { class => 'Koha::Patrons', >+ value => { flags => 2**4, branchcode => $library_3->id } # borrowers flag = 4 >+ } >+ ); >+ my $password = 'thePassword123'; >+ $librarian->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $librarian->userid; >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron_1->id ) >+ ->status_is(200) >+ ->json_is( '/patron_id' => $patron_1->id ); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron_2->id ) >+ ->status_is(200) >+ ->json_is( '/patron_id' => $patron_2->id ); >+ >+ @libraries_where_can_see_patrons = ($library_1->id); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron_1->id ) >+ ->status_is(200) >+ ->json_is( '/patron_id' => $patron_1->id ); >+ >+ $t->get_ok("//$userid:$password@/api/v1/patrons/" . $patron_2->id ) >+ ->status_is(404) >+ ->json_is({ error => "Patron not found." }); >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'add() tests' => sub { >-- >2.34.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 29508
:
127757
|
127758
|
127770
|
127771
|
128671
|
128672