protected function ContentTranslationUITestBase::doTestTranslationDeletion in Drupal 8
Same name in this branch
- 8 core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\ContentTranslationUITestBase::doTestTranslationDeletion()
- 8 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationDeletion()
Tests translation deletion.
1 call to ContentTranslationUITestBase::doTestTranslationDeletion()
- ContentTranslationUITestBase::testTranslationUI in core/
modules/ content_translation/ src/ Tests/ ContentTranslationUITestBase.php - Tests the basic translation UI.
File
- core/
modules/ content_translation/ src/ Tests/ ContentTranslationUITestBase.php, line 365
Class
- ContentTranslationUITestBase
- Tests the Content Translation UI.
Namespace
Drupal\content_translation\TestsCode
protected function doTestTranslationDeletion() {
// Confirm and delete a translation.
$this
->drupalLogin($this->translator);
$langcode = 'fr';
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId);
$language = ConfigurableLanguage::load($langcode);
$url = $entity
->toUrl('edit-form', [
'language' => $language,
]);
$this
->drupalPostForm($url, [], t('Delete translation'));
$this
->drupalPostForm(NULL, [], t('Delete @language translation', [
'@language' => $language
->getName(),
]));
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId, TRUE);
if ($this
->assertTrue(is_object($entity), 'Entity found')) {
$translations = $entity
->getTranslationLanguages();
$this
->assertTrue(count($translations) == 2 && empty($translations[$langcode]), 'Translation successfully deleted.');
}
// Check that the translator cannot delete the original translation.
$args = [
$this->entityTypeId => $entity
->id(),
'language' => 'en',
];
$this
->drupalGet(Url::fromRoute("entity.{$this->entityTypeId}.content_translation_delete", $args));
$this
->assertResponse(403);
}