From eb288de1aa7c72e01895f93bf2742947999d5f4c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 30 Jul 2021 14:53:31 -0300 Subject: [PATCH] Bug 28741: Regression tests This patch adds regression tests for the behavior. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/OAI/Server.t | 58 ++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index 48fea418eb..9294cc604c 100755 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -21,7 +21,7 @@ use Modern::Perl; use Test::Deep qw( cmp_deeply re ); use Test::MockTime qw/set_fixed_time restore_time/; -use Test::More tests => 31; +use Test::More tests => 32; use DateTime; use File::Basename; use File::Spec; @@ -34,6 +34,7 @@ use t::lib::Mocks; use C4::Biblio qw( AddBiblio GetMarcBiblio ModBiblio ); use C4::Context; +use C4::OAI::Sets qw(AddOAISet); use Koha::Biblio::Metadatas; use Koha::Database; @@ -430,3 +431,58 @@ subtest 'Bug 20665: OAI-PMH Provider should reset the MySQL connection time zone $schema->storage->txn_rollback; + +subtest 'ListSets tests' => sub { + + plan tests => 2; + + t::lib::Mocks::mock_preference( 'OAI::PMH' => 1 ); + t::lib::Mocks::mock_preference( 'OAI-PMH:MaxCount' => 3 ); + + $schema->storage->txn_begin; + + $dbh->do('DELETE FROM oai_sets'); + + # Add a bunch of sets + my @sets = (); + for my $i ( 1 .. 3 ) { + + AddOAISet( + { 'spec' => "setSpec_$i", + 'name' => "setName_$i", + } + ); + push @sets, { setSpec => "setSpec_$i", setName => "setName_$i" }; + } + + # Add one more to force pagination + AddOAISet( + { 'spec' => "setSpec_4", + 'name' => "setName_4", + } + ); + + test_query( + 'ListSets', + { verb => 'ListSets' }, + { ListSets => { + resumptionToken => { + content => re( qr{^/3////1/0/3$} ), + cursor => 3, + }, + set => \@sets + } + } + ); + + test_query( + 'ListSets', + { verb => 'ListSets', resumptionToken => "/9/1970-01-01T00:00:00Z///0/0/3" }, + { ListSets => { + set => { setSpec => "setSpec_4", setName => "setName_4" } + } + } + ); + + $schema->storage->txn_rollback; +}; -- 2.32.0