Bug 25570: Regression tests
This tests verify that the default behaviour is to paginate the results.
To test:
1. Apply this patch
2. Run:
$ kshell
k$ prove t/db_dependent/Koha/REST/Plugin/Objects.t
=> FAIL: $c->objects->search doesn't paginate results by default
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 2220ce4d50)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
e6d22b9e9f
commit
fc8bde4178
|
|
@ -80,6 +80,7 @@ get '/biblios' => sub {
|
|||
use Test::More tests => 10;
|
||||
use Test::Mojo;
|
||||
|
||||
use t::lib::Mocks;
|
||||
use t::lib::TestBuilder;
|
||||
use Koha::Database;
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ my $builder = t::lib::TestBuilder->new;
|
|||
|
||||
subtest 'objects.search helper' => sub {
|
||||
|
||||
plan tests => 38;
|
||||
plan tests => 44;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -172,6 +173,25 @@ subtest 'objects.search helper' => sub {
|
|||
->json_is('/2/name' => 'Manuelab')
|
||||
->json_is('/3/name' => 'Emanuel');
|
||||
|
||||
# Add 20 more cities
|
||||
for ( 1..20 ) {
|
||||
$builder->build_object({ class => 'Koha::Cities' });
|
||||
}
|
||||
|
||||
t::lib::Mocks::mock_preference('RESTdefaultPageSize', 20 );
|
||||
$t->get_ok('/cities')
|
||||
->status_is(200);
|
||||
|
||||
my $response_count = scalar @{ $t->tx->res->json };
|
||||
is( $response_count, 20, 'RESTdefaultPageSize is honoured by default (20)' );
|
||||
|
||||
t::lib::Mocks::mock_preference('RESTdefaultPageSize', 5 );
|
||||
$t->get_ok('/cities')
|
||||
->status_is(200);
|
||||
|
||||
$response_count = scalar @{ $t->tx->res->json };
|
||||
is( $response_count, 5, 'RESTdefaultPageSize is honoured by default (5)' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue