From c823eb4aef93c85c4c2d1b500eec0fb752b8699e Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 12 Mar 2019 09:19:56 +0000 Subject: [PATCH] Bug 18589: (follow-up) Add borrowernumber test As per comment #21: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18589#c21 We now test borrowernumber filter works. This test has come from https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=83184&action=diff and will be removed from that bug --- t/db_dependent/api/v1/illrequests.t | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/api/v1/illrequests.t b/t/db_dependent/api/v1/illrequests.t index a0028810e6..fefb96dea9 100644 --- a/t/db_dependent/api/v1/illrequests.t +++ b/t/db_dependent/api/v1/illrequests.t @@ -40,7 +40,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); subtest 'list() tests' => sub { - plan tests => 21; + plan tests => 24; # Mock ILLBackend (as object) my $backend = Test::MockObject->new; @@ -81,7 +81,8 @@ subtest 'list() tests' => sub { $t->request_ok($tx)->status_is(200)->json_is( [] ); my $library = $builder->build_object( { class => 'Koha::Libraries' } ); - my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); + my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); + my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); # Create an ILL request my $illrequest = $builder->build_object( @@ -90,7 +91,7 @@ subtest 'list() tests' => sub { value => { backend => 'Mock', branchcode => $library->branchcode, - borrowernumber => $patron->borrowernumber + borrowernumber => $patron_1->borrowernumber } } ); @@ -114,7 +115,7 @@ subtest 'list() tests' => sub { $tx->req->env( { REMOTE_ADDR => $remote_address } ); $t->request_ok($tx)->status_is(200) ->json_has( '/0/patron', 'patron embedded' ) - ->json_is( '/0/patron/patron_id', $patron->borrowernumber, 'The right patron is embeded') + ->json_is( '/0/patron/patron_id', $patron_1->borrowernumber, 'The right patron is embeded') ->json_has( '/0/requested_partners', 'requested_partners embedded' ) ->json_has( '/0/capabilities', 'capabilities embedded' ) ->json_has( '/0/library', 'library embedded' ) @@ -128,7 +129,7 @@ subtest 'list() tests' => sub { value => { backend => 'Mock', branchcode => $library->branchcode, - borrowernumber => $patron->borrowernumber + borrowernumber => $patron_2->borrowernumber } } ); @@ -154,6 +155,13 @@ subtest 'list() tests' => sub { [{ path => '/query/request_blah', message => 'Malformed query string'}] ); + # Test the borrowernumber parameter + $tx = $t->ua->build_tx( GET => '/api/v1/illrequests?borrowernumber=' . + $patron_2->borrowernumber ); + $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); + $tx->req->env( { REMOTE_ADDR => $remote_address } ); + $t->request_ok($tx)->status_is(200)->json_is( [ $response2 ] ); + $schema->storage->txn_rollback; }; -- 2.11.0