Skip to content
This repository
Browse code

Try to make tests less fragile.

  • Loading branch information...
commit 307759516bd6a2651fa89cc4c163598d3b66c878 1 parent 6d3ae3b
Mark Story authored October 15, 2012

Showing 1 changed file with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. 22  lib/Cake/Test/Case/Utility/CakeTimeTest.php
22  lib/Cake/Test/Case/Utility/CakeTimeTest.php
@@ -779,17 +779,17 @@ public function testUserOffset() {
779 779
 
780 780
 		$expected = time();
781 781
 		$result = $this->Time->fromString(time(), $yourTimezone);
782  
-		$this->assertEquals($expected, $result);
  782
+		$this->assertWithinMargin($expected, $result, 1);
783 783
 
784 784
 		$result = $this->Time->fromString(time(), $timezoneServer->getName());
785  
-		$this->assertEquals($expected, $result);
  785
+		$this->assertWithinMargin($expected, $result, 1);
786 786
 
787 787
 		$result = $this->Time->fromString(time(), $timezoneServer);
788  
-		$this->assertEquals($expected, $result);
  788
+		$this->assertWithinMargin($expected, $result, 1);
789 789
 
790 790
 		Configure::write('Config.timezone', $timezoneServer->getName());
791 791
 		$result = $this->Time->fromString(time());
792  
-		$this->assertEquals($expected, $result);
  792
+		$this->assertWithinMargin($expected, $result, 1);
793 793
 		Configure::delete('Config.timezone');
794 794
 	}
795 795
 
@@ -807,17 +807,17 @@ public function testFromString() {
807 807
 
808 808
 		$result = $this->Time->fromString('+1 hour');
809 809
 		$expected = strtotime('+1 hour');
810  
-		$this->assertEquals($expected, $result);
  810
+		$this->assertWithinMargin($expected, $result, 1);
811 811
 
812 812
 		$timezone = date('Z', time());
813 813
 		$result = $this->Time->fromString('+1 hour', $timezone);
814 814
 		$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
815  
-		$this->assertEquals($expected, $result);
  815
+		$this->assertWithinMargin($expected, $result, 1);
816 816
 
817 817
 		$timezone = date_default_timezone_get();
818 818
 		$result = $this->Time->fromString('+1 hour', $timezone);
819 819
 		$expected = $this->Time->convert(strtotime('+1 hour'), $timezone);
820  
-		$this->assertEquals($expected, $result);
  820
+		$this->assertWithinMargin($expected, $result, 1);
821 821
 
822 822
 		date_default_timezone_set('UTC');
823 823
 		$date = new DateTime('now', new DateTimeZone('Europe/London'));
@@ -840,7 +840,7 @@ public function testFromStringWithDateTime() {
840 840
 		$date->setTimezone(new DateTimeZone('UTC'));
841 841
 		$expected = $date->format('U') + $date->getOffset();
842 842
 
843  
-		$this->assertEquals($expected, $result);
  843
+		$this->assertWithinMargin($expected, $result, 1);
844 844
 
845 845
 		date_default_timezone_set('Australia/Melbourne');
846 846
 
@@ -848,7 +848,7 @@ public function testFromStringWithDateTime() {
848 848
 		$result = $this->Time->fromString($date, 'Asia/Kuwait');
849 849
 		$date->setTimezone(new DateTimeZone('Asia/Kuwait'));
850 850
 		$expected = $date->format('U') + $date->getOffset();
851  
-		$this->assertEquals($expected, $result);
  851
+		$this->assertWithinMargin($expected, $result, 1);
852 852
 
853 853
 		$this->_restoreSystemTimezone();
854 854
 	}
@@ -1058,10 +1058,10 @@ public function testListTimezones() {
1058 1058
 	public function testCorrectTimezoneConversion() {
1059 1059
 		date_default_timezone_set('UTC');
1060 1060
 		$date = '2012-01-01 10:00:00';
1061  
-		$converted = CakeTime::format($date, '%Y-%m-%d %H:%M:%S', '', 'Europe/Copenhagen');
  1061
+		$converted = CakeTime::format($date, '%Y-%m-%d %H:%M', '', 'Europe/Copenhagen');
1062 1062
 		$expected = new DateTime($date);
1063 1063
 		$expected->setTimezone(new DateTimeZone('Europe/Copenhagen'));
1064  
-		$this->assertEquals($expected->format('Y-m-d H:i:s'), $converted);
  1064
+		$this->assertEquals($expected->format('Y-m-d H:i'), $converted);
1065 1065
 	}
1066 1066
 
1067 1067
 }

0 notes on commit 3077595

Please sign in to comment.
Something went wrong with that request. Please try again.