function CommentTranslationUITest::doTestPublishedStatus

Same name in other branches
  1. 8.9.x core/modules/comment/tests/src/Functional/CommentTranslationUITest.php \Drupal\Tests\comment\Functional\CommentTranslationUITest::doTestPublishedStatus()
  2. 10 core/modules/comment/tests/src/Functional/CommentTranslationUITest.php \Drupal\Tests\comment\Functional\CommentTranslationUITest::doTestPublishedStatus()
  3. 11.x core/modules/comment/tests/src/Functional/CommentTranslationUITest.php \Drupal\Tests\comment\Functional\CommentTranslationUITest::doTestPublishedStatus()

Overrides ContentTranslationUITestBase::doTestPublishedStatus

File

core/modules/comment/tests/src/Functional/CommentTranslationUITest.php, line 141

Class

CommentTranslationUITest
Tests the Comment Translation UI.

Namespace

Drupal\Tests\comment\Functional

Code

protected function doTestPublishedStatus() {
    $entity_type_manager = \Drupal::entityTypeManager();
    $storage = $entity_type_manager->getStorage($this->entityTypeId);
    $storage->resetCache();
    $entity = $storage->load($this->entityId);
    // Unpublish translations.
    foreach ($this->langcodes as $index => $langcode) {
        if ($index > 0) {
            $edit = [
                'status' => 0,
            ];
            $url = $entity->toUrl('edit-form', [
                'language' => ConfigurableLanguage::load($langcode),
            ]);
            $this->drupalGet($url);
            $this->submitForm($edit, $this->getFormSubmitAction($entity, $langcode));
            $storage->resetCache();
            $entity = $storage->load($this->entityId);
            $this->assertFalse($this->manager
                ->getTranslationMetadata($entity->getTranslation($langcode))
                ->isPublished(), 'The translation has been correctly unpublished.');
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.