TestsAbstractTestCase

The Simple Calendar Tests AbstractTestCase class.

Defined (1)

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

/vendor/nesbot/carbon/tests/AbstractTestCase.php  
  1. abstract class AbstractTestCase extends PHPUnit_Framework_TestCase 
  2. private $saveTz; 
  3.  
  4. protected function setUp() 
  5. //save current timezone 
  6. $this->saveTz = date_default_timezone_get(); 
  7.  
  8. date_default_timezone_set('America/Toronto'); 
  9.  
  10. protected function tearDown() 
  11. date_default_timezone_set($this->saveTz); 
  12.  
  13. protected function assertCarbon(Carbon $d, $year, $month, $day, $hour = null, $minute = null, $second = null) 
  14. $this->assertSame($year, $d->year, 'Carbon->year'); 
  15. $this->assertSame($month, $d->month, 'Carbon->month'); 
  16. $this->assertSame($day, $d->day, 'Carbon->day'); 
  17.  
  18. if ($hour !== null) { 
  19. $this->assertSame($hour, $d->hour, 'Carbon->hour'); 
  20.  
  21. if ($minute !== null) { 
  22. $this->assertSame($minute, $d->minute, 'Carbon->minute'); 
  23.  
  24. if ($second !== null) { 
  25. $this->assertSame($second, $d->second, 'Carbon->second'); 
  26.  
  27. protected function assertInstanceOfCarbon($d) 
  28. $this->assertInstanceOf('Carbon\Carbon', $d); 
  29.  
  30. protected function assertCarbonInterval(CarbonInterval $ci, $years, $months = null, $days = null, $hours = null, $minutes = null, $seconds = null) 
  31. $this->assertSame($years, $ci->years, 'CarbonInterval->years'); 
  32.  
  33. if ($months !== null) { 
  34. $this->assertSame($months, $ci->months, 'CarbonInterval->months'); 
  35.  
  36. if ($days !== null) { 
  37. $this->assertSame($days, $ci->dayz, 'CarbonInterval->dayz'); 
  38.  
  39. if ($hours !== null) { 
  40. $this->assertSame($hours, $ci->hours, 'CarbonInterval->hours'); 
  41.  
  42. if ($minutes !== null) { 
  43. $this->assertSame($minutes, $ci->minutes, 'CarbonInterval->minutes'); 
  44.  
  45. if ($seconds !== null) { 
  46. $this->assertSame($seconds, $ci->seconds, 'CarbonInterval->seconds'); 
  47.  
  48. protected function assertInstanceOfCarbonInterval($d) 
  49. $this->assertInstanceOf('Carbon\CarbonInterval', $d); 
  50.  
  51. protected function wrapWithTestNow(Closure $func, Carbon $dt = null) 
  52. Carbon::setTestNow(($dt === null) ? Carbon::now() : $dt); 
  53. $func(); 
  54. Carbon::setTestNow();