You are here

protected function EntityTestDatetimeTest::getNormalizedPatchEntity in Drupal 8

Returns the normalized PATCH entity.

By default, reuses ::getNormalizedPostEntity(), which works fine for most entity types. A counterexample: the 'comment' entity type.

Return value

array

Overrides EntityResourceTestBase::getNormalizedPatchEntity

See also

::testPatch

File

core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDatetimeTest.php, line 120

Class

EntityTestDatetimeTest
Tests the datetime field constraint with 'datetime' items.

Namespace

Drupal\Tests\datetime\Functional\EntityResource\EntityTest

Code

protected function getNormalizedPatchEntity() {
  return parent::getNormalizedPostEntity() + [
    static::$fieldName => [
      [
        // Omitting the timezone is allowed, this should result in the site's
        // timezone being used automatically. This does not make sense, but
        // it's how it functioned in the past, so we explicitly test this to
        // guarantee backward compatibility. ::getNormalizedPostEntity() tests
        // the recommended case, this tests backward compatibility.
        'value' => static::$dateString,
      ],
    ],
  ];
}