protected function EntityTranslationUITest::assertOutdatedStatus

Tests up-to-date status tracking.

1 call to EntityTranslationUITest::assertOutdatedStatus()
EntityTranslationUITest::testTranslationUI in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
Tests the basic translation UI.

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php, line 105
Definition of Drupal\entity\Tests\EntityTranslationUITest.

Class

EntityTranslationUITest
Tests the Entity Translation UI.

Namespace

Drupal\translation_entity\Tests

Code

protected function assertOutdatedStatus() {
  $entity = entity_load($this->entityType, $this->entityId, TRUE);
  $langcode = 'fr';
  $default_langcode = $this->langcodes[0];

  // Mark translations as outdated.
  $edit = array(
    'translation_entity[retranslate]' => TRUE,
  );
  $this
    ->drupalPost($langcode . '/' . $this->controller
    ->getEditPath($entity), $edit, $this
    ->getFormSubmitAction($entity));
  $entity = entity_load($this->entityType, $this->entityId, TRUE);

  // Check that every translation has the correct "outdated" status.
  foreach ($this->langcodes as $enabled_langcode) {
    $prefix = $enabled_langcode != $default_langcode ? $enabled_langcode . '/' : '';
    $path = $prefix . $this->controller
      ->getEditPath($entity);
    $this
      ->drupalGet($path);
    if ($enabled_langcode == $langcode) {
      $this
        ->assertFieldByXPath('//input[@name="translation_entity[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.');
    }
    else {
      $this
        ->assertFieldByXPath('//input[@name="translation_entity[outdated]"]', TRUE, 'The translate flag is checked by default.');
      $edit = array(
        'translation_entity[outdated]' => FALSE,
      );
      $this
        ->drupalPost($path, $edit, $this
        ->getFormSubmitAction($entity));
      $this
        ->drupalGet($path);
      $this
        ->assertFieldByXPath('//input[@name="translation_entity[retranslate]"]', FALSE, 'The retranslate flag is now shown.');
      $entity = entity_load($this->entityType, $this->entityId, TRUE);
      $this
        ->assertFalse($entity->translation[$enabled_langcode]['outdated'], 'The "outdated" status has been correctly stored.');
    }
  }
}