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 <mtompset@hotmail.com>

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Ere Maijala 2018-04-26 13:05:51 +00:00 committed by Jonathan Druart
parent de9cfe0c94
commit ebc32f2aae

View file

@ -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;