TestsCarbonStringsTest

The Simple Calendar Tests Carbon StringsTest class.

Defined (1)

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

/vendor/nesbot/carbon/tests/Carbon/StringsTest.php  
  1. class StringsTest extends AbstractTestCase 
  2. public function testToString() 
  3. $d = Carbon::now(); 
  4. $this->assertSame(Carbon::now()->toDateTimeString(), ''.$d); 
  5. public function testSetToStringFormat() 
  6. Carbon::setToStringFormat('jS \o\f F, Y g:i:s a'); 
  7. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  8. $this->assertSame('25th of December, 1975 2:15:16 pm', ''.$d); 
  9. public function testResetToStringFormat() 
  10. $d = Carbon::now(); 
  11. Carbon::setToStringFormat('123'); 
  12. Carbon::resetToStringFormat(); 
  13. $this->assertSame($d->toDateTimeString(), ''.$d); 
  14. public function testExtendedClassToString() 
  15. $d = MyCarbon::now(); 
  16. $this->assertSame($d->toDateTimeString(), ''.$d); 
  17.  
  18. public function testToDateString() 
  19. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  20. $this->assertSame('1975-12-25', $d->toDateString()); 
  21. public function testToFormattedDateString() 
  22. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  23. $this->assertSame('Dec 25, 1975', $d->toFormattedDateString()); 
  24. public function testToLocalizedFormattedDateString() 
  25. /**************** 
  26.   
  27. Working out a Travis issue on how to set a different locale 
  28. other than EN to test this. 
  29.   
  30.   
  31. $cache = setlocale(LC_TIME, 0); 
  32. setlocale(LC_TIME, 'German'); 
  33. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  34. $this->assertSame('Donnerstag 25 Dezember 1975', $d->formatLocalized('%A %d %B %Y')); 
  35. setlocale(LC_TIME, $cache); 
  36.   
  37. *****************/ 
  38. public function testToLocalizedFormattedTimezonedDateString() 
  39. $d = Carbon::create(1975, 12, 25, 14, 15, 16, 'Europe/London'); 
  40. $this->assertSame('Thursday 25 December 1975 14:15', $d->formatLocalized('%A %d %B %Y %H:%M')); 
  41. public function testToTimeString() 
  42. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  43. $this->assertSame('14:15:16', $d->toTimeString()); 
  44. public function testToDateTimeString() 
  45. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  46. $this->assertSame('1975-12-25 14:15:16', $d->toDateTimeString()); 
  47. public function testToDateTimeStringWithPaddedZeroes() 
  48. $d = Carbon::create(2000, 5, 2, 4, 3, 4); 
  49. $this->assertSame('2000-05-02 04:03:04', $d->toDateTimeString()); 
  50. public function testToDayDateTimeString() 
  51. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  52. $this->assertSame('Thu, Dec 25, 1975 2:15 PM', $d->toDayDateTimeString()); 
  53.  
  54. public function testToAtomString() 
  55. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  56. $this->assertSame('1975-12-25T14:15:16-05:00', $d->toAtomString()); 
  57. public function testToCOOKIEString() 
  58. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  59. if (\DateTime::COOKIE === 'l, d-M-y H:i:s T') { 
  60. $cookieString = 'Thursday, 25-Dec-75 14:15:16 EST'; 
  61. } else { 
  62. $cookieString = 'Thursday, 25-Dec-1975 14:15:16 EST'; 
  63.  
  64. $this->assertSame($cookieString, $d->toCOOKIEString()); 
  65. public function testToIso8601String() 
  66. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  67. $this->assertSame('1975-12-25T14:15:16-0500', $d->toIso8601String()); 
  68. public function testToRC822String() 
  69. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  70. $this->assertSame('Thu, 25 Dec 75 14:15:16 -0500', $d->toRfc822String()); 
  71. public function testToRfc850String() 
  72. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  73. $this->assertSame('Thursday, 25-Dec-75 14:15:16 EST', $d->toRfc850String()); 
  74. public function testToRfc1036String() 
  75. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  76. $this->assertSame('Thu, 25 Dec 75 14:15:16 -0500', $d->toRfc1036String()); 
  77. public function testToRfc1123String() 
  78. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  79. $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRfc1123String()); 
  80. public function testToRfc2822String() 
  81. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  82. $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRfc2822String()); 
  83. public function testToRfc3339String() 
  84. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  85. $this->assertSame('1975-12-25T14:15:16-05:00', $d->toRfc3339String()); 
  86. public function testToRssString() 
  87. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  88. $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRssString()); 
  89. public function testToW3cString() 
  90. $d = Carbon::create(1975, 12, 25, 14, 15, 16); 
  91. $this->assertSame('1975-12-25T14:15:16-05:00', $d->toW3cString());