function ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges
Same name in other branches
- 8.9.x core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
- 8.9.x core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
- 10 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
- 11.x core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
Tests the changed time after API and FORM save without changes.
1 call to ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
- ContentTranslationUITestBase::testTranslationUI in core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationUITestBase.php - Tests the basic translation UI.
File
-
core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationUITestBase.php, line 604
Class
- ContentTranslationUITestBase
- Tests the Content Translation UI.
Namespace
Drupal\Tests\content_translation\FunctionalCode
public function doTestChangedTimeAfterSaveWithoutChanges() {
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([
$this->entityId,
]);
$entity = $storage->load($this->entityId);
// Test only entities, which implement the EntityChangedInterface.
if ($entity instanceof EntityChangedInterface) {
$changed_timestamp = $entity->getChangedTime();
$entity->save();
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([
$this->entityId,
]);
$entity = $storage->load($this->entityId);
$this->assertEquals($changed_timestamp, $entity->getChangedTime(), 'The entity\'s changed time wasn\'t updated after API save without changes.');
// Ensure different save timestamps.
sleep(1);
// Save the entity on the regular edit form.
$language = $entity->language();
$edit_path = $entity->toUrl('edit-form', [
'language' => $language,
]);
$this->drupalGet($edit_path);
$this->submitForm([], $this->getFormSubmitAction($entity, $language->getId()));
$storage->resetCache([
$this->entityId,
]);
$entity = $storage->load($this->entityId);
$this->assertNotEquals($changed_timestamp, $entity->getChangedTime(), 'The entity\'s changed time was updated after form save without changes.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.