IssetTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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\CarbonImmutable;
  12. use Carbon\CarbonImmutable as Carbon;
  13. use Generator;
  14. use Tests\AbstractTestCase;
  15. class IssetTest extends AbstractTestCase
  16. {
  17. public function testIssetReturnFalseForUnknownProperty(): void
  18. {
  19. $this->assertFalse(isset($this->immutableNow->sdfsdfss));
  20. }
  21. public static function dataForTestIssetReturnTrueForProperties(): Generator
  22. {
  23. yield ['age'];
  24. yield ['century'];
  25. yield ['day'];
  26. yield ['dayName'];
  27. yield ['dayOfWeek'];
  28. yield ['dayOfWeekIso'];
  29. yield ['dayOfYear'];
  30. yield ['daysInMonth'];
  31. yield ['daysInYear'];
  32. yield ['decade'];
  33. yield ['dst'];
  34. yield ['englishDayOfWeek'];
  35. yield ['englishMonth'];
  36. yield ['firstWeekDay'];
  37. yield ['hour'];
  38. yield ['isoWeek'];
  39. yield ['isoWeekYear'];
  40. yield ['isoWeeksInYear'];
  41. yield ['lastWeekDay'];
  42. yield ['latinMeridiem'];
  43. yield ['latinUpperMeridiem'];
  44. yield ['local'];
  45. yield ['locale'];
  46. yield ['localeDayOfWeek'];
  47. yield ['localeMonth'];
  48. yield ['meridiem'];
  49. yield ['micro'];
  50. yield ['microsecond'];
  51. yield ['millennium'];
  52. yield ['milli'];
  53. yield ['millisecond'];
  54. yield ['milliseconds'];
  55. yield ['minDayName'];
  56. yield ['minute'];
  57. yield ['month'];
  58. yield ['monthName'];
  59. yield ['noZeroHour'];
  60. yield ['offset'];
  61. yield ['offsetHours'];
  62. yield ['offsetMinutes'];
  63. yield ['quarter'];
  64. yield ['second'];
  65. yield ['shortDayName'];
  66. yield ['shortEnglishDayOfWeek'];
  67. yield ['shortEnglishMonth'];
  68. yield ['shortLocaleDayOfWeek'];
  69. yield ['shortLocaleMonth'];
  70. yield ['shortMonthName'];
  71. yield ['timestamp'];
  72. yield ['timezone'];
  73. yield ['timezoneAbbreviatedName'];
  74. yield ['timezoneName'];
  75. yield ['tz'];
  76. yield ['tzAbbrName'];
  77. yield ['tzName'];
  78. yield ['upperMeridiem'];
  79. yield ['utc'];
  80. yield ['week'];
  81. yield ['weekNumberInMonth'];
  82. yield ['weekOfMonth'];
  83. yield ['weekOfYear'];
  84. yield ['weekYear'];
  85. yield ['weeksInYear'];
  86. yield ['year'];
  87. yield ['yearIso'];
  88. }
  89. /**
  90. * @dataProvider \Tests\CarbonImmutable\IssetTest::dataForTestIssetReturnTrueForProperties
  91. *
  92. * @param string $property
  93. */
  94. public function testIssetReturnTrueForProperties(string $property): void
  95. {
  96. Carbon::useStrictMode(false);
  97. $this->assertTrue(isset($this->immutableNow->{$property}));
  98. }
  99. }