From 339930ae890c1e3c53aeff260c9084e3ac4c1c1d Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Thu, 26 Apr 2018 13:05:51 +0000 Subject: [PATCH] Bug 20665: Units tests for testing MySQL connection time zone TEST PLAN --------- apply this test patch prove t/db_dependent/OAI/Server.t -- should fail apply the other patch prove t/db_dependent/OAI/Server.t -- should pass run koha qa test tools Signed-off-by: Mark Tompsett Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/OAI/Server.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index 7309c4a3ab..f924994850 100644 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -20,7 +20,7 @@ use Modern::Perl; use Test::MockTime qw/set_fixed_time restore_time/; -use Test::More tests => 29; +use Test::More tests => 30; use DateTime; use Test::MockModule; use Test::Warn; @@ -376,4 +376,26 @@ subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_me }); }; +subtest 'Bug 20665: OAI-PMH Provider should reset the MySQL connection time zone' => sub { + plan tests => 2; + + # Set time zone to SYSTEM so that it can be checked later + $dbh->do("SET time_zone='SYSTEM'"); + + + test_query('ListIdentifiers without metadataPrefix', {verb => 'ListIdentifiers'}, { + error => { + code => 'badArgument', + content => "Required argument 'metadataPrefix' was undefined", + }, + }); + + my $sth = C4::Context->dbh->prepare('SELECT @@session.time_zone'); + $sth->execute(); + my ( $tz ) = $sth->fetchrow(); + + ok ( $tz eq 'SYSTEM', 'MySQL connection time zone is SYSTEM' ); +}; + + $schema->storage->txn_rollback; -- 2.17.0