public function ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges in Drupal 8
Same name in this branch
- 8 core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
- 8 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
Test the changed time after API and FORM save without changes.
1 call to ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges()
- ContentTranslationUITestBase::testTranslationUI in core/
modules/ content_translation/ src/ Tests/ ContentTranslationUITestBase.php - Tests the basic translation UI.
File
- core/
modules/ content_translation/ src/ Tests/ ContentTranslationUITestBase.php, line 602
Class
- ContentTranslationUITestBase
- Tests the Content Translation UI.
Namespace
Drupal\content_translation\TestsCode
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
->assertEqual($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
->drupalPostForm($edit_path, [], $this
->getFormSubmitAction($entity, $language
->getId()));
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId);
$this
->assertNotEqual($changed_timestamp, $entity
->getChangedTime(), 'The entity\'s changed time was updated after form save without changes.');
}
}