View | Details | Raw Unified | Return to bug 24487
Collapse All | Expand All

(-)a/t/db_dependent/Koha/REST/Plugin/Objects.t (-2 / +30 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Koha::Acquisition::Orders;
20
use Koha::Acquisition::Orders;
21
use Koha::Cities;
21
use Koha::Cities;
22
use Koha::Holds;
22
23
23
# Dummy app for testing the plugin
24
# Dummy app for testing the plugin
24
use Mojolicious::Lite;
25
use Mojolicious::Lite;
Lines 44-51 get '/orders' => sub { Link Here
44
    $c->render( status => 200, json => $orders );
45
    $c->render( status => 200, json => $orders );
45
};
46
};
46
47
48
get '/patrons/:patron_id/holds' => sub {
49
    my $c = shift;
50
    my $params = $c->req->params->to_hash;
51
    $params->{patron_id} = $c->stash("patron_id");
52
    $c->validation->output($params);
53
    my $holds_set = Koha::Holds->new;
54
    my $holds     = $c->objects->search( $holds_set );
55
    $c->render( status => 200, json => {count => scalar(@$holds)} );
56
};
57
47
# The tests
58
# The tests
48
use Test::More tests => 3;
59
use Test::More tests => 4;
49
use Test::Mojo;
60
use Test::Mojo;
50
61
51
use t::lib::TestBuilder;
62
use t::lib::TestBuilder;
Lines 176-178 subtest 'objects.search helper, embed' => sub { Link Here
176
187
177
    $schema->storage->txn_rollback;
188
    $schema->storage->txn_rollback;
178
};
189
};
179
- 
190
191
subtest 'objects.search helper, with path parameters and _match' => sub {
192
    plan tests => 4;
193
194
    $schema->storage->txn_begin;
195
196
    Koha::Holds->search()->delete;
197
198
    $builder->build_object({class=>"Koha::Holds", value => {borrowernumber => 10 }});
199
200
    $t->get_ok('/patrons/1/holds?_match=exact')
201
      ->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=exact');
202
203
    $t->get_ok('/patrons/1/holds?_match=contains')
204
      ->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=contains');
205
206
    $schema->storage->txn_rollback;
207
};

Return to bug 24487