Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Try to make tests less fragile.

  • Loading branch information...
commit 307759516bd6a2651fa89cc4c163598d3b66c878 1 parent 6d3ae3b
@markstory markstory authored
Showing with 11 additions and 11 deletions.
  1. +11 −11 lib/Cake/Test/Case/Utility/CakeTimeTest.php
View
22 lib/Cake/Test/Case/Utility/CakeTimeTest.php
@@ -779,17 +779,17 @@ public function testUserOffset() {
$expected = time();
$result = $this->Time->fromString(time(), $yourTimezone);
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
$result = $this->Time->fromString(time(), $timezoneServer->getName());
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
$result = $this->Time->fromString(time(), $timezoneServer);
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
Configure::write('Config.timezone', $timezoneServer->getName());
$result = $this->Time->fromString(time());
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
Configure::delete('Config.timezone');
}
@@ -807,17 +807,17 @@ public function testFromString() {
$result = $this->Time->fromString('+1 hour');
$expected = strtotime('+1 hour');
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
$timezone = date('Z', time());
$result = $this->Time->fromString('+1 hour', $timezone);
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
$timezone = date_default_timezone_get();
$result = $this->Time->fromString('+1 hour', $timezone);
$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
date_default_timezone_set('UTC');
$date = new DateTime('now', new DateTimeZone('Europe/London'));
@@ -840,7 +840,7 @@ public function testFromStringWithDateTime() {
$date->setTimezone(new DateTimeZone('UTC'));
$expected = $date->format('U') + $date->getOffset();
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
date_default_timezone_set('Australia/Melbourne');
@@ -848,7 +848,7 @@ public function testFromStringWithDateTime() {
$result = $this->Time->fromString($date, 'Asia/Kuwait');
$date->setTimezone(new DateTimeZone('Asia/Kuwait'));
$expected = $date->format('U') + $date->getOffset();
- $this->assertEquals($expected, $result);
+ $this->assertWithinMargin($expected, $result, 1);
$this->_restoreSystemTimezone();
}
@@ -1058,10 +1058,10 @@ public function testListTimezones() {
public function testCorrectTimezoneConversion() {
date_default_timezone_set('UTC');
$date = '2012-01-01 10:00:00';
- $converted = CakeTime::format($date, '%Y-%m-%d %H:%M:%S', '', 'Europe/Copenhagen');
+ $converted = CakeTime::format($date, '%Y-%m-%d %H:%M', '', 'Europe/Copenhagen');
$expected = new DateTime($date);
$expected->setTimezone(new DateTimeZone('Europe/Copenhagen'));
- $this->assertEquals($expected->format('Y-m-d H:i:s'), $converted);
+ $this->assertEquals($expected->format('Y-m-d H:i'), $converted);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.