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

(-)a/t/db_dependent/Koha/REST/Plugin/Objects.t (-13 / +12 lines)
Lines 31-37 plugin 'Koha::REST::Plugin::Pagination'; Link Here
31
get '/cities' => sub {
31
get '/cities' => sub {
32
    my $c = shift;
32
    my $c = shift;
33
    $c->validation->output($c->req->params->to_hash);
33
    $c->validation->output($c->req->params->to_hash);
34
    my $cities = $c->objects->search(Koha::Cities->new);
34
    my $cities = $c->objects->search(Koha::Cities->new, \&to_model );
35
    $c->render( status => 200, json => $cities );
35
    $c->render( status => 200, json => $cities );
36
};
36
};
37
37
Lines 152-169 subtest 'objects.search helper' => sub { Link Here
152
    });
152
    });
153
153
154
    # _match=starts_with
154
    # _match=starts_with
155
    $t->get_ok('/cities?name=manuel&_per_page=4&_page=1&_match=starts_with')
155
    $t->get_ok('/cities?nombre=manuel&_per_page=4&_page=1&_match=starts_with')
156
        ->status_is(200)
156
        ->status_is(200)
157
        ->json_has('/0')
157
        ->json_has('/0')
158
        ->json_has('/1')
158
        ->json_has('/1')
159
        ->json_has('/2')
159
        ->json_has('/2')
160
        ->json_hasnt('/3')
160
        ->json_hasnt('/3')
161
        ->json_is('/0/name' => 'Manuel')
161
        ->json_is('/0/city_name' => 'Manuel')
162
        ->json_is('/1/name' => 'Manuela')
162
        ->json_is('/1/city_name' => 'Manuela')
163
        ->json_is('/2/name' => 'Manuelab');
163
        ->json_is('/2/city_name' => 'Manuelab');
164
164
165
    # _match=ends_with
165
    # _match=ends_with
166
    $t->get_ok('/cities?name=manuel&_per_page=4&_page=1&_match=ends_with')
166
    $t->get_ok('/cities?nombre=manuel&_per_page=4&_page=1&_match=ends_with')
167
        ->status_is(200)
167
        ->status_is(200)
168
        ->json_has('/0')
168
        ->json_has('/0')
169
        ->json_has('/1')
169
        ->json_has('/1')
Lines 172-195 subtest 'objects.search helper' => sub { Link Here
172
        ->json_is('/1/city_name' => 'Emanuel');
172
        ->json_is('/1/city_name' => 'Emanuel');
173
173
174
    # _match=exact
174
    # _match=exact
175
    $t->get_ok('/cities?name=manuel&_per_page=4&_page=1&_match=exact')
175
    $t->get_ok('/cities?nombre=manuel&_per_page=4&_page=1&_match=exact')
176
        ->status_is(200)
176
        ->status_is(200)
177
        ->json_has('/0')
177
        ->json_has('/0')
178
        ->json_hasnt('/1')
178
        ->json_hasnt('/1')
179
        ->json_is('/0/city_name' => 'Manuel');
179
        ->json_is('/0/city_name' => 'Manuel');
180
180
181
    # _match=contains
181
    # _match=contains
182
    $t->get_ok('/cities?name=manuel&_per_page=4&_page=1&_match=contains')
182
    $t->get_ok('/cities?nombre=manuel&_per_page=4&_page=1&_match=contains')
183
        ->status_is(200)
183
        ->status_is(200)
184
        ->json_has('/0')
184
        ->json_has('/0')
185
        ->json_has('/1')
185
        ->json_has('/1')
186
        ->json_has('/2')
186
        ->json_has('/2')
187
        ->json_has('/3')
187
        ->json_has('/3')
188
        ->json_hasnt('/4')
188
        ->json_hasnt('/4')
189
        ->json_is('/0/name' => 'Manuel')
189
        ->json_is('/0/city_name' => 'Manuel')
190
        ->json_is('/1/name' => 'Manuela')
190
        ->json_is('/1/city_name' => 'Manuela')
191
        ->json_is('/2/name' => 'Manuelab')
191
        ->json_is('/2/city_name' => 'Manuelab')
192
        ->json_is('/3/name' => 'Emanuel');
192
        ->json_is('/3/city_name' => 'Emanuel');
193
193
194
    $schema->storage->txn_rollback;
194
    $schema->storage->txn_rollback;
195
};
195
};
196
- 

Return to bug 22522