function DateTestBase::massageTestDate

Same name in other branches
  1. 9 core/modules/datetime/tests/src/Functional/DateTestBase.php \Drupal\Tests\datetime\Functional\DateTestBase::massageTestDate()
  2. 8.9.x core/modules/datetime/src/Tests/DateTestBase.php \Drupal\datetime\Tests\DateTestBase::massageTestDate()
  3. 8.9.x core/modules/datetime/tests/src/Functional/DateTestBase.php \Drupal\Tests\datetime\Functional\DateTestBase::massageTestDate()
  4. 11.x 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 203

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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.