TestFixture.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Carbon package.
  4. *
  5. * (c) Brian Nesbitt <brian@nesbot.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. require __DIR__.'/../vendor/autoload.php';
  11. use Carbon\Carbon;
  12. class TestFixture extends \PHPUnit_Framework_TestCase
  13. {
  14. private $saveTz;
  15. protected function setUp()
  16. {
  17. //save current timezone
  18. $this->saveTz = date_default_timezone_get();
  19. date_default_timezone_set('America/Toronto');
  20. }
  21. protected function tearDown()
  22. {
  23. date_default_timezone_set($this->saveTz);
  24. }
  25. protected function assertCarbon(Carbon $d, $year, $month, $day, $hour = null, $minute = null, $second = null)
  26. {
  27. $this->assertSame($year, $d->year, 'Carbon->year');
  28. $this->assertSame($month, $d->month, 'Carbon->month');
  29. $this->assertSame($day, $d->day, 'Carbon->day');
  30. if ($hour !== null) {
  31. $this->assertSame($hour, $d->hour, 'Carbon->hour');
  32. }
  33. if ($minute !== null) {
  34. $this->assertSame($minute, $d->minute, 'Carbon->minute');
  35. }
  36. if ($second !== null) {
  37. $this->assertSame($second, $d->second, 'Carbon->second');
  38. }
  39. }
  40. }