protected function TermTranslationUITest::doTestPublishedStatus in Drupal 10
Same name and namespace in other branches
- 8 core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php \Drupal\Tests\taxonomy\Functional\TermTranslationUITest::doTestPublishedStatus()
- 9 core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php \Drupal\Tests\taxonomy\Functional\TermTranslationUITest::doTestPublishedStatus()
File
- core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php, line 184
Class
- TermTranslationUITest
- Tests the Term Translation UI.
Namespace
Drupal\Tests\taxonomy\Functional
Code
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) {
foreach ($this->langcodes as $langcode) {
$options = [
'language' => $languages[$langcode],
];
$url = $entity
->toUrl('edit-form', $options);
$this
->drupalGet($url, $options);
$this
->submitForm([
'status[value]' => $value,
], 'Save');
}
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId);
foreach ($this->langcodes as $langcode) {
$status = !$index;
$translation = $entity
->getTranslation($langcode);
$this
->assertEquals($status, $this->manager
->getTranslationMetadata($translation)
->isPublished(), 'The translation has been correctly unpublished.');
}
}
}