function TimestampFormatterWithTimeDiffTest::testNoRefreshInterval
Same name in other branches
- 10 core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffTest.php \Drupal\FunctionalJavascriptTests\Core\Field\TimestampFormatterWithTimeDiffTest::testNoRefreshInterval()
Tests the 'timestamp' formatter without refresh interval.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ Core/ Field/ TimestampFormatterWithTimeDiffTest.php, line 141
Class
- TimestampFormatterWithTimeDiffTest
- Tests the 'timestamp' formatter when is used with time difference setting.
Namespace
Drupal\FunctionalJavascriptTests\Core\FieldCode
public function testNoRefreshInterval() : void {
$this->markTestSkipped("Skipped due to frequent random test failures. See https://www.drupal.org/project/drupal/issues/3400150");
// Set the refresh interval to zero, meaning "no refresh".
$display = EntityViewDisplay::load('entity_test.entity_test.default');
$component = $display->getComponent('time_field');
$component['settings']['time_diff']['refresh'] = 0;
$display->setComponent('time_field', $component)
->save();
$this->drupalGet($this->entity
->toUrl());
$time_element = $this->getSession()
->getPage()
->find('css', 'time');
$time_diff_text = $time_element->getText();
$time_diff_settings = Json::decode($time_element->getAttribute('data-drupal-time-diff'));
// Check that the timestamp is represented as a time difference.
$this->assertMatchesRegularExpression('/^\\d+ seconds? ago$/', $time_diff_text);
// Check that the refresh is zero (no refresh).
$this->assertSame(0, $time_diff_settings['refresh']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.