You are here

protected function DateTestBase::massageTestDate in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/datetime/tests/src/Functional/DateTestBase.php \Drupal\Tests\datetime\Functional\DateTestBase::massageTestDate()

Massages test date values.

If a date object is generated directly by a test, then it needs to be adjusted to behave like the computed date from the item.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $date: A date object directly generated by the test.

2 calls to DateTestBase::massageTestDate()
DateRangeFieldTest::testDateRangeField in core/modules/datetime_range/tests/src/Functional/DateRangeFieldTest.php
Tests date field functionality.
DateTimeFieldTest::testDateField in core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php
Tests date field functionality.

File

core/modules/datetime/tests/src/Functional/DateTestBase.php, line 200

Class

DateTestBase
Provides a base class for testing Datetime field functionality.

Namespace

Drupal\Tests\datetime\Functional

Code

protected function massageTestDate($date) {
  if ($this->field
    ->getSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE) {

    // Set the default time for date-only items.
    $date
      ->setDefaultDateTime();
  }
}