function DateTimeTimeAgoFormatterTest::testSettings

Same name in other branches
  1. 8.9.x core/modules/datetime/tests/src/Functional/DateTimeTimeAgoFormatterTest.php \Drupal\Tests\datetime\Functional\DateTimeTimeAgoFormatterTest::testSettings()
  2. 10 core/modules/datetime/tests/src/Functional/DateTimeTimeAgoFormatterTest.php \Drupal\Tests\datetime\Functional\DateTimeTimeAgoFormatterTest::testSettings()
  3. 11.x core/modules/datetime/tests/src/Functional/DateTimeTimeAgoFormatterTest.php \Drupal\Tests\datetime\Functional\DateTimeTimeAgoFormatterTest::testSettings()

Tests the formatter settings.

File

core/modules/datetime/tests/src/Functional/DateTimeTimeAgoFormatterTest.php, line 105

Class

DateTimeTimeAgoFormatterTest
Tests the functionality of DateTimeTimeAgoFormatter field formatter.

Namespace

Drupal\Tests\datetime\Functional

Code

public function testSettings() {
    $this->drupalGet('entity_test/structure/entity_test/display');
    $edit = [
        'fields[field_datetime][region]' => 'content',
        'fields[field_datetime][type]' => 'datetime_time_ago',
    ];
    $this->submitForm($edit, 'Save');
    $this->submitForm([], 'field_datetime_settings_edit');
    $edit = [
        'fields[field_datetime][settings_edit_form][settings][future_format]' => 'ends in @interval',
        'fields[field_datetime][settings_edit_form][settings][past_format]' => 'started @interval ago',
        'fields[field_datetime][settings_edit_form][settings][granularity]' => 1,
    ];
    $this->submitForm($edit, 'Update');
    $this->submitForm([], 'Save');
    $this->assertSession()
        ->pageTextContains('ends in 1 year');
    $this->assertSession()
        ->pageTextContains('started 1 year ago');
}

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