TestsCarbonCreateFromTimestampTest

The Simple Calendar Tests Carbon CreateFromTimestampTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/nesbot/carbon/tests/Carbon/CreateFromTimestampTest.php  
  1. class CreateFromTimestampTest extends AbstractTestCase 
  2. public function testCreateReturnsDatingInstance() 
  3. $d = Carbon::createFromTimestamp(Carbon::create(1975, 5, 21, 22, 32, 5)->timestamp); 
  4. $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5); 
  5.  
  6. public function testCreateFromTimestampUsesDefaultTimezone() 
  7. $d = Carbon::createFromTimestamp(0); 
  8.  
  9. // We know Toronto is -5 since no DST in Jan 
  10. $this->assertSame(1969, $d->year); 
  11. $this->assertSame(-5 * 3600, $d->offset); 
  12.  
  13. public function testCreateFromTimestampWithDateTimeZone() 
  14. $d = Carbon::createFromTimestamp(0, new \DateTimeZone('UTC')); 
  15. $this->assertSame('UTC', $d->tzName); 
  16. $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); 
  17.  
  18. public function testCreateFromTimestampWithString() 
  19. $d = Carbon::createFromTimestamp(0, 'UTC'); 
  20. $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); 
  21. $this->assertSame(0, $d->offset); 
  22. $this->assertSame('UTC', $d->tzName); 
  23.  
  24. public function testCreateFromTimestampGMTDoesNotUseDefaultTimezone() 
  25. $d = Carbon::createFromTimestampUTC(0); 
  26. $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); 
  27. $this->assertSame(0, $d->offset);