Browse Source

Fixed tests for Time::toUnixString()

Jose Lorenzo Rodriguez 12 years ago
parent
commit
64abd3fe64
2 changed files with 6 additions and 7 deletions
  1. 1 1
      src/Utility/Time.php
  2. 5 6
      tests/TestCase/Utility/TimeTest.php

+ 1 - 1
src/Utility/Time.php

@@ -174,7 +174,7 @@ class Time extends Carbon {
 /**
  * Returns a UNIX timestamp.
  *
- * @return int Unix timestamp
+ * @return string Unix timestamp
  */
 	public function toUnixString() {
 		return $this->format('U');

+ 5 - 6
tests/TestCase/Utility/TimeTest.php

@@ -374,12 +374,11 @@ class TimeTest extends TestCase {
  * @return void
  */
 	public function testToUnix() {
-		$this->assertEquals(time(), $this->Time->toUnix(time()));
-		$this->assertEquals(strtotime('+1 day'), $this->Time->toUnix('+1 day'));
-		$this->assertEquals(strtotime('+0 days'), $this->Time->toUnix('+0 days'));
-		$this->assertEquals(strtotime('-1 days'), $this->Time->toUnix('-1 days'));
-		$this->assertEquals(false, $this->Time->toUnix(''));
-		$this->assertEquals(false, $this->Time->toUnix(null));
+		$time = new Time('2014-04-20 08:00:00');
+		$this->assertEquals('1397980800', $time->toUnixString());
+
+		$time = new Time('2021-12-11 07:00:01');
+		$this->assertEquals('1639206001', $time->toUnixString());
 	}
 
 /**