protected function NodeTranslationUITest::doTestPublishedStatus in Drupal 8
Same name and namespace in other branches
- 9 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::doTestPublishedStatus()
- 10 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::doTestPublishedStatus()
Tests the translation publishing status.
Overrides ContentTranslationUITestBase::doTestPublishedStatus
File
- core/
modules/ node/ tests/ src/ Functional/ NodeTranslationUITest.php, line 163
Class
- NodeTranslationUITest
- Tests the Node Translation UI.
Namespace
Drupal\Tests\node\FunctionalCode
protected function doTestPublishedStatus() {
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId);
$languages = $this->container
->get('language_manager')
->getLanguages();
$statuses = [
TRUE,
FALSE,
];
foreach ($statuses as $index => $value) {
// (Un)publish the node translations and check that the translation
// statuses are (un)published accordingly.
foreach ($this->langcodes as $langcode) {
$options = [
'language' => $languages[$langcode],
];
$url = $entity
->toUrl('edit-form', $options);
$this
->drupalPostForm($url, [
'status[value]' => $value,
], t('Save') . $this
->getFormSubmitSuffix($entity, $langcode), $options);
}
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId);
foreach ($this->langcodes as $langcode) {
// The node is created as unpublished thus we switch to the published
// status first.
$status = !$index;
$translation = $entity
->getTranslation($langcode);
$this
->assertEqual($status, $this->manager
->getTranslationMetadata($translation)
->isPublished(), 'The translation has been correctly unpublished.');
}
}
}