From 3fc2133aad7ef5a320ea8a3304de65bd8b436b51 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 13 Dec 2018 16:59:40 -0300 Subject: [PATCH] Bug 21460: Add tests --- t/db_dependent/api/v1/illrequests.t | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/api/v1/illrequests.t b/t/db_dependent/api/v1/illrequests.t index fb3eff9bdc..5018f0a280 100644 --- a/t/db_dependent/api/v1/illrequests.t +++ b/t/db_dependent/api/v1/illrequests.t @@ -39,7 +39,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); subtest 'list() tests' => sub { - plan tests => 18; + plan tests => 21; # Mock ILLBackend (as object) my $backend = Test::MockObject->new; @@ -80,7 +80,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( @@ -89,7 +90,7 @@ subtest 'list() tests' => sub { value => { backend => 'Mock', branchcode => $library->branchcode, - borrowernumber => $patron->borrowernumber + borrowernumber => $patron_1->borrowernumber } } ); @@ -122,7 +123,7 @@ subtest 'list() tests' => sub { value => { backend => 'Mock', branchcode => $library->branchcode, - borrowernumber => $patron->borrowernumber + borrowernumber => $patron_2->borrowernumber } } ); @@ -146,6 +147,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