TestsCarbonIsTest

The Simple Calendar Tests Carbon IsTest class.

Defined (1)

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

/vendor/nesbot/carbon/tests/Carbon/IsTest.php  
  1. class IsTest extends AbstractTestCase 
  2. public function testIsWeekdayTrue() 
  3. $this->assertTrue(Carbon::createFromDate(2012, 1, 2)->isWeekday()); 
  4.  
  5. public function testIsWeekdayFalse() 
  6. $this->assertFalse(Carbon::createFromDate(2012, 1, 1)->isWeekday()); 
  7.  
  8. public function testIsWeekendTrue() 
  9. $this->assertTrue(Carbon::createFromDate(2012, 1, 1)->isWeekend()); 
  10.  
  11. public function testIsWeekendFalse() 
  12. $this->assertFalse(Carbon::createFromDate(2012, 1, 2)->isWeekend()); 
  13.  
  14. public function testIsYesterdayTrue() 
  15. $this->assertTrue(Carbon::now()->subDay()->isYesterday()); 
  16.  
  17. public function testIsYesterdayFalseWithToday() 
  18. $this->assertFalse(Carbon::now()->endOfDay()->isYesterday()); 
  19.  
  20. public function testIsYesterdayFalseWith2Days() 
  21. $this->assertFalse(Carbon::now()->subDays(2)->startOfDay()->isYesterday()); 
  22.  
  23. public function testIsTodayTrue() 
  24. $this->assertTrue(Carbon::now()->isToday()); 
  25.  
  26. public function testIsTodayFalseWithYesterday() 
  27. $this->assertFalse(Carbon::now()->subDay()->endOfDay()->isToday()); 
  28.  
  29. public function testIsTodayFalseWithTomorrow() 
  30. $this->assertFalse(Carbon::now()->addDay()->startOfDay()->isToday()); 
  31.  
  32. public function testIsTodayWithTimezone() 
  33. $this->assertTrue(Carbon::now('Asia/Tokyo')->isToday()); 
  34.  
  35. public function testIsTomorrowTrue() 
  36. $this->assertTrue(Carbon::now()->addDay()->isTomorrow()); 
  37.  
  38. public function testIsTomorrowFalseWithToday() 
  39. $this->assertFalse(Carbon::now()->endOfDay()->isTomorrow()); 
  40.  
  41. public function testIsTomorrowFalseWith2Days() 
  42. $this->assertFalse(Carbon::now()->addDays(2)->startOfDay()->isTomorrow()); 
  43.  
  44. public function testIsFutureTrue() 
  45. $this->assertTrue(Carbon::now()->addSecond()->isFuture()); 
  46.  
  47. public function testIsFutureFalse() 
  48. $this->assertFalse(Carbon::now()->isFuture()); 
  49.  
  50. public function testIsFutureFalseInThePast() 
  51. $this->assertFalse(Carbon::now()->subSecond()->isFuture()); 
  52.  
  53. public function testIsPastTrue() 
  54. $this->assertTrue(Carbon::now()->subSecond()->isPast()); 
  55.  
  56. public function testIsPastFalse() 
  57. $this->assertFalse(Carbon::now()->addSecond()->isPast()); 
  58. $this->assertFalse(Carbon::now()->isPast()); 
  59.  
  60. public function testIsLeapYearTrue() 
  61. $this->assertTrue(Carbon::createFromDate(2016, 1, 1)->isLeapYear()); 
  62.  
  63. public function testIsLeapYearFalse() 
  64. $this->assertFalse(Carbon::createFromDate(2014, 1, 1)->isLeapYear()); 
  65.  
  66. public function testIsSameDayTrue() 
  67. $current = Carbon::createFromDate(2012, 1, 2); 
  68. $this->assertTrue($current->isSameDay(Carbon::createFromDate(2012, 1, 2))); 
  69.  
  70. public function testIsSameDayFalse() 
  71. $current = Carbon::createFromDate(2012, 1, 2); 
  72. $this->assertFalse($current->isSameDay(Carbon::createFromDate(2012, 1, 3))); 
  73.  
  74. public function testIsSunday() 
  75. // True in the past past 
  76. $this->assertTrue(Carbon::createFromDate(2015, 5, 31)->isSunday()); 
  77. $this->assertTrue(Carbon::createFromDate(2015, 6, 21)->isSunday()); 
  78. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isSunday()); 
  79.  
  80. // True in the future 
  81. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::SUNDAY)->isSunday()); 
  82. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isSunday()); 
  83.  
  84. // False in the past 
  85. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::MONDAY)->isSunday()); 
  86. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::MONDAY)->isSunday()); 
  87.  
  88. // False in the future 
  89. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::MONDAY)->isSunday()); 
  90. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isSunday()); 
  91.  
  92. public function testIsMonday() 
  93. // True in the past past 
  94. $this->assertTrue(Carbon::createFromDate(2015, 6, 1)->isMonday()); 
  95. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::MONDAY)->isMonday()); 
  96.  
  97. // True in the future 
  98. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::MONDAY)->isMonday()); 
  99. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::MONDAY)->isMonday()); 
  100.  
  101. // False in the past 
  102. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::TUESDAY)->isMonday()); 
  103. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::TUESDAY)->isMonday()); 
  104.  
  105. // False in the future 
  106. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::TUESDAY)->isMonday()); 
  107. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::TUESDAY)->isMonday()); 
  108.  
  109. public function testIsTuesday() 
  110. // True in the past past 
  111. $this->assertTrue(Carbon::createFromDate(2015, 6, 2)->isTuesday()); 
  112. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::TUESDAY)->isTuesday()); 
  113.  
  114. // True in the future 
  115. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::TUESDAY)->isTuesday()); 
  116. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::TUESDAY)->isTuesday()); 
  117.  
  118. // False in the past 
  119. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::WEDNESDAY)->isTuesday()); 
  120. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::WEDNESDAY)->isTuesday()); 
  121.  
  122. // False in the future 
  123. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::WEDNESDAY)->isTuesday()); 
  124. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::WEDNESDAY)->isTuesday()); 
  125.  
  126. public function testIsWednesday() 
  127. // True in the past past 
  128. $this->assertTrue(Carbon::createFromDate(2015, 6, 3)->isWednesday()); 
  129. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::WEDNESDAY)->isWednesday()); 
  130.  
  131. // True in the future 
  132. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::WEDNESDAY)->isWednesday()); 
  133. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::WEDNESDAY)->isWednesday()); 
  134.  
  135. // False in the past 
  136. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::THURSDAY)->isWednesday()); 
  137. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::THURSDAY)->isWednesday()); 
  138.  
  139. // False in the future 
  140. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::THURSDAY)->isWednesday()); 
  141. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::THURSDAY)->isWednesday()); 
  142.  
  143. public function testIsThursday() 
  144. // True in the past past 
  145. $this->assertTrue(Carbon::createFromDate(2015, 6, 4)->isThursday()); 
  146. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::THURSDAY)->isThursday()); 
  147.  
  148. // True in the future 
  149. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::THURSDAY)->isThursday()); 
  150. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::THURSDAY)->isThursday()); 
  151.  
  152. // False in the past 
  153. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::FRIDAY)->isThursday()); 
  154. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::FRIDAY)->isThursday()); 
  155.  
  156. // False in the future 
  157. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::FRIDAY)->isThursday()); 
  158. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::FRIDAY)->isThursday()); 
  159.  
  160. public function testIsFriday() 
  161. // True in the past past 
  162. $this->assertTrue(Carbon::createFromDate(2015, 6, 5)->isFriday()); 
  163. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::FRIDAY)->isFriday()); 
  164.  
  165. // True in the future 
  166. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::FRIDAY)->isFriday()); 
  167. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::FRIDAY)->isFriday()); 
  168.  
  169. // False in the past 
  170. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::SATURDAY)->isFriday()); 
  171. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::SATURDAY)->isFriday()); 
  172.  
  173. // False in the future 
  174. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::SATURDAY)->isFriday()); 
  175. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::SATURDAY)->isFriday()); 
  176.  
  177. public function testIsSaturday() 
  178. // True in the past past 
  179. $this->assertTrue(Carbon::createFromDate(2015, 6, 6)->isSaturday()); 
  180. $this->assertTrue(Carbon::now()->subWeek()->previous(Carbon::SATURDAY)->isSaturday()); 
  181.  
  182. // True in the future 
  183. $this->assertTrue(Carbon::now()->addWeek()->previous(Carbon::SATURDAY)->isSaturday()); 
  184. $this->assertTrue(Carbon::now()->addMonth()->previous(Carbon::SATURDAY)->isSaturday()); 
  185.  
  186. // False in the past 
  187. $this->assertFalse(Carbon::now()->subWeek()->previous(Carbon::SUNDAY)->isSaturday()); 
  188. $this->assertFalse(Carbon::now()->subMonth()->previous(Carbon::SUNDAY)->isSaturday()); 
  189.  
  190. // False in the future 
  191. $this->assertFalse(Carbon::now()->addWeek()->previous(Carbon::SUNDAY)->isSaturday()); 
  192. $this->assertFalse(Carbon::now()->addMonth()->previous(Carbon::SUNDAY)->isSaturday());