You are here

public function DateTimeIso8601NormalizerTest::providerTestNormalize in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::providerTestNormalize()
  2. 9 core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\DateTimeIso8601NormalizerTest::providerTestNormalize()

Data provider for testNormalize.

Return value

array

File

core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php, line 154

Class

DateTimeIso8601NormalizerTest
Unit test coverage for the "datetime_iso8601" @DataType.

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function providerTestNormalize() {
  return [
    // @see \Drupal\datetime\Plugin\Field\FieldType\DateTimeItem::DATETIME_TYPE_DATE
    'datetime field, configured to store only date: must be handled by DateTimeIso8601Normalizer' => [
      DateTimeItem::class,
      DateTimeItem::DATETIME_TYPE_DATE,
      // This expected format call proves that normalization is handled by \Drupal\serialization\Normalizer\DateTimeIso8601Normalizer::normalize().
      'Y-m-d',
    ],
    // @see \Drupal\datetime\Plugin\Field\FieldType\DateTimeItem::DATETIME_TYPE_DATETIME
    'datetime field, configured to store date and time; must be handled by the parent normalizer' => [
      DateTimeItem::class,
      DateTimeItem::DATETIME_TYPE_DATETIME,
      \DateTime::RFC3339,
    ],
    'non-datetime field; must be handled by the parent normalizer' => [
      FieldItemBase::class,
      NULL,
      \DateTime::RFC3339,
    ],
  ];
}