You are here

protected function ContentTranslationUITestBase::doTestPublishedStatus 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::doTestPublishedStatus()

Tests the translation publishing status.

1 call to ContentTranslationUITestBase::doTestPublishedStatus()
ContentTranslationUITestBase::testTranslationUI in core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
Tests the basic translation UI.
2 methods override ContentTranslationUITestBase::doTestPublishedStatus()
CommentTranslationUITest::doTestPublishedStatus in core/modules/comment/src/Tests/CommentTranslationUITest.php
Tests the translation publishing status.
NodeTranslationUITest::doTestPublishedStatus in core/modules/node/src/Tests/NodeTranslationUITest.php
Tests the translation publishing status.

File

core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php, line 269
Contains \Drupal\content_translation\Tests\ContentTranslationUITestBase.

Class

ContentTranslationUITestBase
Tests the Content Translation UI.

Namespace

Drupal\content_translation\Tests

Code

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

  // Unpublish translations.
  foreach ($this->langcodes as $index => $langcode) {
    if ($index > 0) {
      $url = $entity
        ->urlInfo('edit-form', array(
        'language' => ConfigurableLanguage::load($langcode),
      ));
      $edit = array(
        'content_translation[status]' => FALSE,
      );
      $this
        ->drupalPostForm($url, $edit, $this
        ->getFormSubmitAction($entity, $langcode));
      $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
      $this
        ->assertFalse($this->manager
        ->getTranslationMetadata($entity
        ->getTranslation($langcode))
        ->isPublished(), 'The translation has been correctly unpublished.');
    }
  }

  // Check that the last published translation cannot be unpublished.
  $this
    ->drupalGet($entity
    ->urlInfo('edit-form'));
  $this
    ->assertFieldByXPath('//input[@name="content_translation[status]" and @disabled="disabled"]', TRUE, 'The last translation is published and cannot be unpublished.');
}