@@ -, +, @@ --- t/db_dependent/Koha/REST/Plugin/Objects.t | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) --- a/t/db_dependent/Koha/REST/Plugin/Objects.t +++ a/t/db_dependent/Koha/REST/Plugin/Objects.t @@ -19,6 +19,7 @@ use Modern::Perl; use Koha::Acquisition::Orders; use Koha::Cities; +use Koha::Holds; # Dummy app for testing the plugin use Mojolicious::Lite; @@ -44,8 +45,16 @@ get '/orders' => sub { $c->render( status => 200, json => $orders ); }; +get '/patrons/:patron_id/holds' => sub { + my $c = shift; + $c->validation->output($c->req->params->to_hash); + my $holds_set = Koha::Holds->new; + my $holds = $c->objects->search( $holds_set ); + $c->render( status => 200, json => {count => scalar(@$holds)} ); +}; + # The tests -use Test::More tests => 3; +use Test::More tests => 4; use Test::Mojo; use t::lib::TestBuilder; @@ -176,3 +185,18 @@ subtest 'objects.search helper, embed' => sub { $schema->storage->txn_rollback; }; + +subtest 'objects.search helper, with path parameters and _match' => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + Koha::Holds->search()->delete; + + $builder->build_object({class=>"Koha::Holds", value => {borrowernumber => 10 }}); + + $t->get_ok('/patrons/1/holds?_match=contains') + ->json_is('/count' => 0, 'there should be no holds for borrower 1'); + + $schema->storage->txn_rollback; +}; --