function TimestampAgoFormatterTest::testSettings

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Datetime/TimestampAgoFormatterTest.php \Drupal\FunctionalTests\Datetime\TimestampAgoFormatterTest::testSettings()
  2. 10 core/tests/Drupal/FunctionalTests/Datetime/TimestampAgoFormatterTest.php \Drupal\FunctionalTests\Datetime\TimestampAgoFormatterTest::testSettings()
  3. 11.x core/tests/Drupal/FunctionalTests/Datetime/TimestampAgoFormatterTest.php \Drupal\FunctionalTests\Datetime\TimestampAgoFormatterTest::testSettings()

Tests the formatter settings.

File

core/tests/Drupal/FunctionalTests/Datetime/TimestampAgoFormatterTest.php, line 105

Class

TimestampAgoFormatterTest
Tests the functionality of TimestampAgoFormatter core field formatter.

Namespace

Drupal\FunctionalTests\Datetime

Code

public function testSettings() {
    $this->drupalGet('entity_test/structure/entity_test/display');
    $edit = [
        'fields[field_timestamp][region]' => 'content',
        'fields[field_timestamp][type]' => 'timestamp_ago',
    ];
    $this->drupalPostForm(NULL, $edit, t('Save'));
    $this->drupalPostForm(NULL, [], 'field_timestamp_settings_edit');
    $edit = [
        'fields[field_timestamp][settings_edit_form][settings][future_format]' => 'ends in @interval',
        'fields[field_timestamp][settings_edit_form][settings][past_format]' => 'started @interval ago',
        'fields[field_timestamp][settings_edit_form][settings][granularity]' => 1,
    ];
    $this->drupalPostForm(NULL, $edit, 'Update');
    $this->drupalPostForm(NULL, [], '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.