TestsCarbonDayOfWeekModifiersTest

The Simple Calendar Tests Carbon DayOfWeekModifiersTest class.

Defined (1)

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

/vendor/nesbot/carbon/tests/Carbon/DayOfWeekModifiersTest.php  
  1. class DayOfWeekModifiersTest extends AbstractTestCase 
  2. public function testStartOfWeek() 
  3. $d = Carbon::create(1980, 8, 7, 12, 11, 9)->startOfWeek(); 
  4. $this->assertCarbon($d, 1980, 8, 4, 0, 0, 0); 
  5.  
  6. public function testStartOfWeekFromWeekStart() 
  7. $d = Carbon::createFromDate(1980, 8, 4)->startOfWeek(); 
  8. $this->assertCarbon($d, 1980, 8, 4, 0, 0, 0); 
  9.  
  10. public function testStartOfWeekCrossingYearBoundary() 
  11. $d = Carbon::createFromDate(2013, 12, 31, 'GMT'); 
  12. $d->startOfWeek(); 
  13. $this->assertCarbon($d, 2013, 12, 30, 0, 0, 0); 
  14.  
  15. public function testEndOfWeek() 
  16. $d = Carbon::create(1980, 8, 7, 11, 12, 13)->endOfWeek(); 
  17. $this->assertCarbon($d, 1980, 8, 10, 23, 59, 59); 
  18.  
  19. public function testEndOfWeekFromWeekEnd() 
  20. $d = Carbon::createFromDate(1980, 8, 9)->endOfWeek(); 
  21. $this->assertCarbon($d, 1980, 8, 10, 23, 59, 59); 
  22.  
  23. public function testEndOfWeekCrossingYearBoundary() 
  24. $d = Carbon::createFromDate(2013, 12, 31, 'GMT'); 
  25. $d->endOfWeek(); 
  26. $this->assertCarbon($d, 2014, 1, 5, 23, 59, 59); 
  27.  
  28. public function testNext() 
  29. $d = Carbon::createFromDate(1975, 5, 21)->next(); 
  30. $this->assertCarbon($d, 1975, 5, 28, 0, 0, 0); 
  31.  
  32. public function testNextMonday() 
  33. $d = Carbon::createFromDate(1975, 5, 21)->next(Carbon::MONDAY); 
  34. $this->assertCarbon($d, 1975, 5, 26, 0, 0, 0); 
  35.  
  36. public function testNextSaturday() 
  37. $d = Carbon::createFromDate(1975, 5, 21)->next(6); 
  38. $this->assertCarbon($d, 1975, 5, 24, 0, 0, 0); 
  39.  
  40. public function testNextTimestamp() 
  41. $d = Carbon::createFromDate(1975, 11, 14)->next(); 
  42. $this->assertCarbon($d, 1975, 11, 21, 0, 0, 0); 
  43.  
  44. public function testPrevious() 
  45. $d = Carbon::createFromDate(1975, 5, 21)->previous(); 
  46. $this->assertCarbon($d, 1975, 5, 14, 0, 0, 0); 
  47.  
  48. public function testPreviousMonday() 
  49. $d = Carbon::createFromDate(1975, 5, 21)->previous(Carbon::MONDAY); 
  50. $this->assertCarbon($d, 1975, 5, 19, 0, 0, 0); 
  51.  
  52. public function testPreviousSaturday() 
  53. $d = Carbon::createFromDate(1975, 5, 21)->previous(6); 
  54. $this->assertCarbon($d, 1975, 5, 17, 0, 0, 0); 
  55.  
  56. public function testPreviousTimestamp() 
  57. $d = Carbon::createFromDate(1975, 11, 28)->previous(); 
  58. $this->assertCarbon($d, 1975, 11, 21, 0, 0, 0); 
  59.  
  60. public function testFirstDayOfMonth() 
  61. $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(); 
  62. $this->assertCarbon($d, 1975, 11, 1, 0, 0, 0); 
  63.  
  64. public function testFirstWednesdayOfMonth() 
  65. $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(Carbon::WEDNESDAY); 
  66. $this->assertCarbon($d, 1975, 11, 5, 0, 0, 0); 
  67.  
  68. public function testFirstFridayOfMonth() 
  69. $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(5); 
  70. $this->assertCarbon($d, 1975, 11, 7, 0, 0, 0); 
  71.  
  72. public function testLastDayOfMonth() 
  73. $d = Carbon::createFromDate(1975, 12, 5)->lastOfMonth(); 
  74. $this->assertCarbon($d, 1975, 12, 31, 0, 0, 0); 
  75.  
  76. public function testLastTuesdayOfMonth() 
  77. $d = Carbon::createFromDate(1975, 12, 1)->lastOfMonth(Carbon::TUESDAY); 
  78. $this->assertCarbon($d, 1975, 12, 30, 0, 0, 0); 
  79.  
  80. public function testLastFridayOfMonth() 
  81. $d = Carbon::createFromDate(1975, 12, 5)->lastOfMonth(5); 
  82. $this->assertCarbon($d, 1975, 12, 26, 0, 0, 0); 
  83.  
  84. public function testNthOfMonthOutsideScope() 
  85. $this->assertFalse(Carbon::createFromDate(1975, 12, 5)->nthOfMonth(6, Carbon::MONDAY)); 
  86.  
  87. public function testNthOfMonthOutsideYear() 
  88. $this->assertFalse(Carbon::createFromDate(1975, 12, 5)->nthOfMonth(55, Carbon::MONDAY)); 
  89.  
  90. public function test2ndMondayOfMonth() 
  91. $d = Carbon::createFromDate(1975, 12, 5)->nthOfMonth(2, Carbon::MONDAY); 
  92. $this->assertCarbon($d, 1975, 12, 8, 0, 0, 0); 
  93.  
  94. public function test3rdWednesdayOfMonth() 
  95. $d = Carbon::createFromDate(1975, 12, 5)->nthOfMonth(3, 3); 
  96. $this->assertCarbon($d, 1975, 12, 17, 0, 0, 0); 
  97.  
  98. public function testFirstDayOfQuarter() 
  99. $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(); 
  100. $this->assertCarbon($d, 1975, 10, 1, 0, 0, 0); 
  101.  
  102. public function testFirstWednesdayOfQuarter() 
  103. $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(Carbon::WEDNESDAY); 
  104. $this->assertCarbon($d, 1975, 10, 1, 0, 0, 0); 
  105.  
  106. public function testFirstFridayOfQuarter() 
  107. $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(5); 
  108. $this->assertCarbon($d, 1975, 10, 3, 0, 0, 0); 
  109.  
  110. public function testFirstOfQuarterFromADayThatWillNotExistIntheFirstMonth() 
  111. $d = Carbon::createFromDate(2014, 5, 31)->firstOfQuarter(); 
  112. $this->assertCarbon($d, 2014, 4, 1, 0, 0, 0); 
  113.  
  114. public function testLastDayOfQuarter() 
  115. $d = Carbon::createFromDate(1975, 8, 5)->lastOfQuarter(); 
  116. $this->assertCarbon($d, 1975, 9, 30, 0, 0, 0); 
  117.  
  118. public function testLastTuesdayOfQuarter() 
  119. $d = Carbon::createFromDate(1975, 8, 1)->lastOfQuarter(Carbon::TUESDAY); 
  120. $this->assertCarbon($d, 1975, 9, 30, 0, 0, 0); 
  121.  
  122. public function testLastFridayOfQuarter() 
  123. $d = Carbon::createFromDate(1975, 7, 5)->lastOfQuarter(5); 
  124. $this->assertCarbon($d, 1975, 9, 26, 0, 0, 0); 
  125.  
  126. public function testLastOfQuarterFromADayThatWillNotExistIntheLastMonth() 
  127. $d = Carbon::createFromDate(2014, 5, 31)->lastOfQuarter(); 
  128. $this->assertCarbon($d, 2014, 6, 30, 0, 0, 0); 
  129.  
  130. public function testNthOfQuarterOutsideScope() 
  131. $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfQuarter(20, Carbon::MONDAY)); 
  132.  
  133. public function testNthOfQuarterOutsideYear() 
  134. $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfQuarter(55, Carbon::MONDAY)); 
  135.  
  136. public function testNthOfQuarterFromADayThatWillNotExistIntheFirstMonth() 
  137. $d = Carbon::createFromDate(2014, 5, 31)->nthOfQuarter(2, Carbon::MONDAY); 
  138. $this->assertCarbon($d, 2014, 4, 14, 0, 0, 0); 
  139.  
  140. public function test2ndMondayOfQuarter() 
  141. $d = Carbon::createFromDate(1975, 8, 5)->nthOfQuarter(2, Carbon::MONDAY); 
  142. $this->assertCarbon($d, 1975, 7, 14, 0, 0, 0); 
  143.  
  144. public function test3rdWednesdayOfQuarter() 
  145. $d = Carbon::createFromDate(1975, 8, 5)->nthOfQuarter(3, 3); 
  146. $this->assertCarbon($d, 1975, 7, 16, 0, 0, 0); 
  147.  
  148. public function testFirstDayOfYear() 
  149. $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(); 
  150. $this->assertCarbon($d, 1975, 1, 1, 0, 0, 0); 
  151.  
  152. public function testFirstWednesdayOfYear() 
  153. $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(Carbon::WEDNESDAY); 
  154. $this->assertCarbon($d, 1975, 1, 1, 0, 0, 0); 
  155.  
  156. public function testFirstFridayOfYear() 
  157. $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(5); 
  158. $this->assertCarbon($d, 1975, 1, 3, 0, 0, 0); 
  159.  
  160. public function testLastDayOfYear() 
  161. $d = Carbon::createFromDate(1975, 8, 5)->lastOfYear(); 
  162. $this->assertCarbon($d, 1975, 12, 31, 0, 0, 0); 
  163.  
  164. public function testLastTuesdayOfYear() 
  165. $d = Carbon::createFromDate(1975, 8, 1)->lastOfYear(Carbon::TUESDAY); 
  166. $this->assertCarbon($d, 1975, 12, 30, 0, 0, 0); 
  167.  
  168. public function testLastFridayOfYear() 
  169. $d = Carbon::createFromDate(1975, 7, 5)->lastOfYear(5); 
  170. $this->assertCarbon($d, 1975, 12, 26, 0, 0, 0); 
  171.  
  172. public function testNthOfYearOutsideScope() 
  173. $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfYear(55, Carbon::MONDAY)); 
  174.  
  175. public function test2ndMondayOfYear() 
  176. $d = Carbon::createFromDate(1975, 8, 5)->nthOfYear(2, Carbon::MONDAY); 
  177. $this->assertCarbon($d, 1975, 1, 13, 0, 0, 0); 
  178.  
  179. public function test3rdWednesdayOfYear() 
  180. $d = Carbon::createFromDate(1975, 8, 5)->nthOfYear(3, 3); 
  181. $this->assertCarbon($d, 1975, 1, 15, 0, 0, 0);