You are here

protected function CommentTranslationUITest::doTestPublishedStatus in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/comment/tests/src/Functional/CommentTranslationUITest.php \Drupal\Tests\comment\Functional\CommentTranslationUITest::doTestPublishedStatus()
  2. 9 core/modules/comment/tests/src/Functional/CommentTranslationUITest.php \Drupal\Tests\comment\Functional\CommentTranslationUITest::doTestPublishedStatus()

File

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

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.');
    }
  }
}