SetStartEndOfWeekTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of the Carbon package.
  5. *
  6. * (c) Brian Nesbitt <brian@nesbot.com>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Tests\Carbon;
  12. use Carbon\Carbon;
  13. use Tests\AbstractTestCase;
  14. class SetStartEndOfWeekTest extends AbstractTestCase
  15. {
  16. public function testSetStartOfWeekLessThanMin()
  17. {
  18. Carbon::setWeekStartsAt(Carbon::SUNDAY - 1);
  19. $this->assertSame(Carbon::SATURDAY, Carbon::getWeekStartsAt());
  20. }
  21. public function testSetStartOfWeekMoreThanMax()
  22. {
  23. Carbon::setWeekStartsAt(Carbon::SATURDAY + 1);
  24. $this->assertSame(Carbon::SUNDAY, Carbon::getWeekStartsAt());
  25. }
  26. public function testSetStartOfWeekValid()
  27. {
  28. for ($i = Carbon::SUNDAY; $i < Carbon::SATURDAY; $i++) {
  29. Carbon::setWeekStartsAt($i);
  30. $this->assertSame($i, Carbon::getWeekStartsAt());
  31. }
  32. }
  33. public function testSetEndOfWeekLessThanMin()
  34. {
  35. Carbon::setWeekEndsAt(Carbon::SUNDAY - 1);
  36. $this->assertSame(Carbon::SATURDAY, Carbon::getWeekEndsAt());
  37. }
  38. public function testSetEndOfWeekMoreThanMax()
  39. {
  40. Carbon::setWeekEndsAt(Carbon::SATURDAY + 1);
  41. $this->assertSame(Carbon::SUNDAY, Carbon::getWeekEndsAt());
  42. }
  43. public function testSetEndOfWeekValid()
  44. {
  45. for ($i = Carbon::SUNDAY; $i < Carbon::SATURDAY; $i++) {
  46. Carbon::setWeekEndsAt($i);
  47. $this->assertSame($i, Carbon::getWeekEndsAt());
  48. }
  49. }
  50. }