Bugzilla – Attachment 180778 Details for
Bug 39600
Paginate (and modernize) OPAC ILL requests table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39600: Add tests for patron_list
Bug-39600-Add-tests-for-patronlist.patch (text/plain), 3.66 KB, created by
HKS3 Tadeusz Sośnierz
on 2025-04-10 13:36:19 UTC
(
hide
)
Description:
Bug 39600: Add tests for patron_list
Filename:
MIME Type:
Creator:
HKS3 Tadeusz Sośnierz
Created:
2025-04-10 13:36:19 UTC
Size:
3.66 KB
patch
obsolete
>From 498ee5fd8a592de8c4ac0cce2fad56d4b7c59ed0 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= > <tadeusz@sosnierz.com> >Date: Thu, 10 Apr 2025 15:34:26 +0200 >Subject: [PATCH] Bug 39600: Add tests for patron_list > >Sponsored-by: Wiko (https://www.wiko-berlin.de/) >--- > t/db_dependent/api/v1/ill_requests.t | 82 +++++++++++++++++++++++++++- > 1 file changed, 81 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/api/v1/ill_requests.t b/t/db_dependent/api/v1/ill_requests.t >index be961d8a87..830a2def2b 100755 >--- a/t/db_dependent/api/v1/ill_requests.t >+++ b/t/db_dependent/api/v1/ill_requests.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 3; >+use Test::More tests => 4; > > use Test::MockModule; > use Test::MockObject; >@@ -264,6 +264,86 @@ subtest 'list() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'patron_list() tests' => sub { >+ >+ plan tests => 15; >+ >+ # Mock ILLBackend (as object) >+ my $backend = Test::MockObject->new; >+ $backend->set_isa('Koha::Illbackends::Mock'); >+ $backend->set_always( 'name', 'Mock' ); >+ $backend->mock( >+ 'status_graph', sub { }, >+ ); >+ >+ # Mock Koha::ILL::Request::load_backend (to load Mocked Backend) >+ my $illreqmodule = Test::MockModule->new('Koha::ILL::Request'); >+ $illreqmodule->mock( >+ 'load_backend', >+ sub { my $self = shift; $self->{_my_backend} = $backend; return $self } >+ ); >+ >+ $schema->storage->txn_begin; >+ >+ Koha::ILL::Requests->search->delete; >+ >+ my $requester = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } >+ } >+ ); >+ my $password = 'thePassword123'; >+ $requester->set_password( { password => $password, skip_validation => 1 } ); >+ my $requester_userid = $requester->userid; >+ my $requester_number = $requester->borrowernumber; >+ >+ my $observer = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 0 } >+ } >+ ); >+ >+ $observer->set_password( { password => $password, skip_validation => 1 } ); >+ my $observer_userid = $observer->userid; >+ my $observer_number = $observer->borrowernumber; >+ >+ # No requests yet, expect empty for both >+ $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( [] ); >+ $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)->json_is( [] ); >+ >+ for (0..25) { >+ $builder->build_object( >+ { >+ class => 'Koha::ILL::Requests', >+ value => { >+ borrowernumber => $requester_number, >+ batch_id => undef, >+ status => 'NEW', >+ backend => $backend->name, >+ notesstaff => 'secret staff notes' >+ } >+ } >+ ); >+ } >+ >+ # Other user should not see anything >+ $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)->json_is( [] ); >+ >+ # Staff notes hidden in the public API >+ $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( >+ '/0/staff_notes' => undef, >+ ); >+ >+ # Not all requests get returned, pagination works >+ $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( >+ '/21' => undef, >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'add() tests' => sub { > > plan tests => 2; >-- >2.47.2
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 39600
:
180758
|
180759
|
180760
|
180761
|
180762
|
180763
|
180764
|
180778
|
180781
|
180785
|
180786
|
180787
|
180821