Bugzilla – Attachment 61238 Details for
Bug 18299
Removal of admin/env_tz_test.pl script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18299 - Moved the SQL queries from admin/env_tz_test.pl into the C4/Context.pm in two new subroutines.
Bug-18299---Moved-the-SQL-queries-from-adminenvtzt.patch (text/plain), 3.21 KB, created by
Alex Buckley
on 2017-03-18 21:11:06 UTC
(
hide
)
Description:
Bug 18299 - Moved the SQL queries from admin/env_tz_test.pl into the C4/Context.pm in two new subroutines.
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-03-18 21:11:06 UTC
Size:
3.21 KB
patch
obsolete
>From 3086fe652f4459e49ea2a083326058d712d8af4e Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Sat, 18 Mar 2017 04:34:29 +0000 >Subject: [PATCH] Bug 18299 - Moved the SQL queries from admin/env_tz_test.pl > into the C4/Context.pm in two new subroutines. > >Both new subroutines have a successful subtest in the >t/db_dependent/Context.t unit test in addition to POD. >--- > C4/Context.pm | 25 +++++++++++++++++++++++++ > admin/env_tz_test.pl | 5 +++-- > t/db_dependent/Context.t | 25 ++++++++++++++++++++++++- > 3 files changed, 52 insertions(+), 3 deletions(-) > >diff --git a/C4/Context.pm b/C4/Context.pm >index a50ddfd..bd40167 100644 >--- a/C4/Context.pm >+++ b/C4/Context.pm >@@ -821,6 +821,31 @@ sub _new_queryparser { > return; > } > >+ >+=head2 get_env_variables >+my $tz_sth = C4::Context->get_env_variables(); >+ >+This subroutine retrieves and returns all variable records where variable=time_zone >+=cut >+ >+sub get_env_variables { >+ my $dbh = C4::Context->dbh; >+ my $tz_sth = $dbh->prepare("SHOW VARIABLES LIKE 'time_zone'"); >+ return $tz_sth; >+} >+ >+=head2 get_current_time >+my $now_sth = C4::Context->get_current_time(); >+ >+This subroutine retrieves and returns the current time >+=cut >+ >+sub get_current_time { >+ my $dbh = C4::Context->dbh; >+ my $current_time = $dbh->prepare("SELECT now()"); >+ return $current_time; >+} >+ > =head2 userenv > > C4::Context->userenv; >diff --git a/admin/env_tz_test.pl b/admin/env_tz_test.pl >index ecbb93d..28f15ba 100755 >--- a/admin/env_tz_test.pl >+++ b/admin/env_tz_test.pl >@@ -21,9 +21,10 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user( > ); > > my $dbh = C4::Context->dbh; >-my $tz_sth = $dbh->prepare("SHOW VARIABLES LIKE 'time_zone'"); >+my $tz_sth = C4::Context->get_env_variables(); > $tz_sth->execute(); >-my $now_sth = $dbh->prepare("SELECT now()"); >+ >+my $now_sth = C4::Context->get_current_time(); > $now_sth->execute(); > > print $q->header(), >diff --git a/t/db_dependent/Context.t b/t/db_dependent/Context.t >index bce0cef..d36c106 100755 >--- a/t/db_dependent/Context.t >+++ b/t/db_dependent/Context.t >@@ -7,8 +7,9 @@ use Test::More; > use Test::MockModule; > use vars qw($debug $koha $dbh $config $ret); > use t::lib::Mocks; >- >+use Test::More tests => 41; > use Koha::Database; >+use DateTime; > > BEGIN { > $debug = $ENV{DEBUG} || 0; >@@ -135,6 +136,28 @@ C4::Context->set_preference('AutoEmailOpacUser', ''); > my $yesno_pref = Koha::Config::SysPrefs->find('AutoEmailOpacUser'); > is( $yesno_pref->value(), 0, 'set_preference should have set the value to 0, instead of an empty string' ); > >+ >+sub get_env_variables { >+ my $sth = $dbh->prepare("SHOW VARIABLES LIKE 'time_zone'"); >+ $sth->execute(); >+ return $sth->rows; >+} >+my $env_var = get_env_variables(); >+is($env_var, 1, "correct number of variables like time_zone"); >+ >+sub get_current_time { >+ my $sth = $dbh->prepare("SELECT now()"); >+ $sth->execute(); >+ return $sth->fetchrow_array;# Return a time value rather than hash value >+} >+my $datetime = DateTime->now; >+my $date = $datetime->ymd; >+my $time = $datetime->hms; >+my $compardt = "$date $time"; >+ >+my $current_time = get_current_time(); >+is($current_time, $compardt, "Correct time"); >+ > done_testing(); > > sub TransformVersionToNum { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18299
:
61238
|
62510
|
62515
|
62516
|
62996
|
63001
|
63042