You are here

public function ContentTranslationUITestBase::doTestChangedTimeAfterSaveWithoutChanges in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\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 558
Contains \Drupal\content_translation\Tests\ContentTranslationUITestBase.

Class

ContentTranslationUITestBase
Tests the Content Translation UI.

Namespace

Drupal\content_translation\Tests

Code

public function doTestChangedTimeAfterSaveWithoutChanges() {
  $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);

  // Test only entities, which implement the EntityChangedInterface.
  if ($entity
    ->getEntityType()
    ->isSubclassOf('Drupal\\Core\\Entity\\EntityChangedInterface')) {
    $changed_timestamp = $entity
      ->getChangedTime();
    $entity
      ->save();
    $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
    $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
      ->urlInfo('edit-form', array(
      'language' => $language,
    ));
    $this
      ->drupalPostForm($edit_path, [], $this
      ->getFormSubmitAction($entity, $language
      ->getId()));
    $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
    $this
      ->assertNotEqual($changed_timestamp, $entity
      ->getChangedTime(), 'The entity\'s changed time was updated after form save without changes.');
  }
}