Skip to content

Commit

Permalink
Making tests more robust to timezone differences
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 15, 2014
1 parent 5cdd8ac commit ae2127e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Test/TestCase/Database/QueryTest.php
Expand Up @@ -1923,6 +1923,7 @@ function($q) {
$result = $query
->select(['d' => $query->func()->now('time')])
->execute();

$this->assertWithinMargin(
date('U'),
(new \DateTime($result->fetchAll('assoc')[0]['d']))->format('U'),
Expand Down
4 changes: 3 additions & 1 deletion Test/init.php
Expand Up @@ -59,6 +59,7 @@

require CORE_PATH . 'Cake/bootstrap.php';

date_default_timezone_set('UTC');
mb_internal_encoding('UTF-8');

Configure::write('debug', 2);
Expand Down Expand Up @@ -98,7 +99,8 @@
'dsn' => getenv('db_dsn'),
'database' => getenv('db_database'),
'login' => getenv('db_login'),
'password' => getenv('db_password')
'password' => getenv('db_password'),
'timezone' => 'UTC'
]);

Configure::write('Session', [
Expand Down

0 comments on commit ae2127e

Please sign in to comment.