protected function NodeTranslationUITest::assertPublishedStatus

Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::assertPublishedStatus().

Overrides EntityTranslationUITest::assertPublishedStatus

File

drupal/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php, line 81
Definition of Drupal\node\Tests\NodeTranslationUITest.

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\node\Tests

Code

protected function assertPublishedStatus() {
  $entity = entity_load($this->entityType, $this->entityId, TRUE);
  $path = $this->controller
    ->getEditPath($entity);
  $languages = language_list();
  $actions = array(
    array(
      t('Save and publish'),
      t('Save and keep published'),
    ),
    array(
      t('Save and unpublish'),
      t('Save and keep unpublished'),
    ),
  );
  foreach ($actions as $index => $status_actions) {

    // (Un)publish the node translations and check that the translation
    // statuses are (un)published accordingly.
    foreach ($this->langcodes as $langcode) {
      if (!empty($status_actions)) {
        $action = array_shift($status_actions);
      }
      $this
        ->drupalPost($path, array(), $action, array(
        'language' => $languages[$langcode],
      ));
    }
    $entity = entity_load($this->entityType, $this->entityId, TRUE);
    foreach ($this->langcodes as $langcode) {

      // The node is created as unpulished thus we switch to the published
      // status first.
      $status = !$index;
      $this
        ->assertEqual($status, $entity->translation[$langcode]['status'], 'The translation has been correctly unpublished.');
    }
  }
}