TestsCarbonStartEndOfTest

The Simple Calendar Tests Carbon StartEndOfTest class.

Defined (1)

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

/vendor/nesbot/carbon/tests/Carbon/StartEndOfTest.php  
  1. class StartEndOfTest extends AbstractTestCase 
  2. public function testStartOfDay() 
  3. $dt = Carbon::now(); 
  4. $this->assertTrue($dt->startOfDay() instanceof Carbon); 
  5. $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, 0, 0, 0); 
  6.  
  7. public function testEndOfDay() 
  8. $dt = Carbon::now(); 
  9. $this->assertTrue($dt->endOfDay() instanceof Carbon); 
  10. $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, 23, 59, 59); 
  11.  
  12. public function testStartOfMonthIsFluid() 
  13. $dt = Carbon::now(); 
  14. $this->assertTrue($dt->startOfMonth() instanceof Carbon); 
  15.  
  16. public function testStartOfMonthFromNow() 
  17. $dt = Carbon::now()->startOfMonth(); 
  18. $this->assertCarbon($dt, $dt->year, $dt->month, 1, 0, 0, 0); 
  19.  
  20. public function testStartOfMonthFromLastDay() 
  21. $dt = Carbon::create(2000, 1, 31, 2, 3, 4)->startOfMonth(); 
  22. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  23.  
  24. public function testStartOfYearIsFluid() 
  25. $dt = Carbon::now(); 
  26. $this->assertTrue($dt->startOfYear() instanceof Carbon); 
  27.  
  28. public function testStartOfYearFromNow() 
  29. $dt = Carbon::now()->startOfYear(); 
  30. $this->assertCarbon($dt, $dt->year, 1, 1, 0, 0, 0); 
  31.  
  32. public function testStartOfYearFromFirstDay() 
  33. $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfYear(); 
  34. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  35.  
  36. public function testStartOfYearFromLastDay() 
  37. $dt = Carbon::create(2000, 12, 31, 23, 59, 59)->startOfYear(); 
  38. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  39.  
  40. public function testEndOfMonthIsFluid() 
  41. $dt = Carbon::now(); 
  42. $this->assertTrue($dt->endOfMonth() instanceof Carbon); 
  43.  
  44. public function testEndOfMonth() 
  45. $dt = Carbon::create(2000, 1, 1, 2, 3, 4)->endOfMonth(); 
  46. $this->assertCarbon($dt, 2000, 1, 31, 23, 59, 59); 
  47.  
  48. public function testEndOfMonthFromLastDay() 
  49. $dt = Carbon::create(2000, 1, 31, 2, 3, 4)->endOfMonth(); 
  50. $this->assertCarbon($dt, 2000, 1, 31, 23, 59, 59); 
  51.  
  52. public function testEndOfYearIsFluid() 
  53. $dt = Carbon::now(); 
  54. $this->assertTrue($dt->endOfYear() instanceof Carbon); 
  55.  
  56. public function testEndOfYearFromNow() 
  57. $dt = Carbon::now()->endOfYear(); 
  58. $this->assertCarbon($dt, $dt->year, 12, 31, 23, 59, 59); 
  59.  
  60. public function testEndOfYearFromFirstDay() 
  61. $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfYear(); 
  62. $this->assertCarbon($dt, 2000, 12, 31, 23, 59, 59); 
  63.  
  64. public function testEndOfYearFromLastDay() 
  65. $dt = Carbon::create(2000, 12, 31, 23, 59, 59)->endOfYear(); 
  66. $this->assertCarbon($dt, 2000, 12, 31, 23, 59, 59); 
  67.  
  68. public function testStartOfDecadeIsFluid() 
  69. $dt = Carbon::now(); 
  70. $this->assertTrue($dt->startOfDecade() instanceof Carbon); 
  71.  
  72. public function testStartOfDecadeFromNow() 
  73. $dt = Carbon::now()->startOfDecade(); 
  74. $this->assertCarbon($dt, $dt->year - $dt->year % 10, 1, 1, 0, 0, 0); 
  75.  
  76. public function testStartOfDecadeFromFirstDay() 
  77. $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfDecade(); 
  78. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  79.  
  80. public function testStartOfDecadeFromLastDay() 
  81. $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->startOfDecade(); 
  82. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  83.  
  84. public function testEndOfDecadeIsFluid() 
  85. $dt = Carbon::now(); 
  86. $this->assertTrue($dt->endOfDecade() instanceof Carbon); 
  87.  
  88. public function testEndOfDecadeFromNow() 
  89. $dt = Carbon::now()->endOfDecade(); 
  90. $this->assertCarbon($dt, $dt->year - $dt->year % 10 + 9, 12, 31, 23, 59, 59); 
  91.  
  92. public function testEndOfDecadeFromFirstDay() 
  93. $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfDecade(); 
  94. $this->assertCarbon($dt, 2009, 12, 31, 23, 59, 59); 
  95.  
  96. public function testEndOfDecadeFromLastDay() 
  97. $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->endOfDecade(); 
  98. $this->assertCarbon($dt, 2009, 12, 31, 23, 59, 59); 
  99.  
  100. public function testStartOfCenturyIsFluid() 
  101. $dt = Carbon::now(); 
  102. $this->assertTrue($dt->startOfCentury() instanceof Carbon); 
  103.  
  104. public function testStartOfCenturyFromNow() 
  105. $dt = Carbon::now()->startOfCentury(); 
  106. $this->assertCarbon($dt, $dt->year - $dt->year % 100, 1, 1, 0, 0, 0); 
  107.  
  108. public function testStartOfCenturyFromFirstDay() 
  109. $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfCentury(); 
  110. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  111.  
  112. public function testStartOfCenturyFromLastDay() 
  113. $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->startOfCentury(); 
  114. $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); 
  115.  
  116. public function testEndOfCenturyIsFluid() 
  117. $dt = Carbon::now(); 
  118. $this->assertTrue($dt->endOfCentury() instanceof Carbon); 
  119.  
  120. public function testEndOfCenturyFromNow() 
  121. $dt = Carbon::now()->endOfCentury(); 
  122. $this->assertCarbon($dt, $dt->year - $dt->year % 100 + 99, 12, 31, 23, 59, 59); 
  123.  
  124. public function testEndOfCenturyFromFirstDay() 
  125. $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfCentury(); 
  126. $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); 
  127.  
  128. public function testEndOfCenturyFromLastDay() 
  129. $dt = Carbon::create(2099, 12, 31, 23, 59, 59)->endOfCentury(); 
  130. $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); 
  131.  
  132. public function testAverageIsFluid() 
  133. $dt = Carbon::now()->average(); 
  134. $this->assertTrue($dt instanceof Carbon); 
  135.  
  136. public function testAverageFromSame() 
  137. $dt1 = Carbon::create(2000, 1, 31, 2, 3, 4); 
  138. $dt2 = Carbon::create(2000, 1, 31, 2, 3, 4)->average($dt1); 
  139. $this->assertCarbon($dt2, 2000, 1, 31, 2, 3, 4); 
  140.  
  141. public function testAverageFromGreater() 
  142. $dt1 = Carbon::create(2000, 1, 1, 1, 1, 1); 
  143. $dt2 = Carbon::create(2009, 12, 31, 23, 59, 59)->average($dt1); 
  144. $this->assertCarbon($dt2, 2004, 12, 31, 12, 30, 30); 
  145.  
  146. public function testAverageFromLower() 
  147. $dt1 = Carbon::create(2009, 12, 31, 23, 59, 59); 
  148. $dt2 = Carbon::create(2000, 1, 1, 1, 1, 1)->average($dt1); 
  149. $this->assertCarbon($dt2, 2004, 12, 31, 12, 30, 30);