protected function ContentTranslationUITestBase::doTestTranslationDeletion in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\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 334  - Contains \Drupal\content_translation\Tests\ContentTranslationUITestBase.
 
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';
  $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
  $language = ConfigurableLanguage::load($langcode);
  $url = $entity
    ->urlInfo('edit-form', array(
    'language' => $language,
  ));
  $this
    ->drupalPostForm($url, array(), t('Delete translation'));
  $this
    ->drupalPostForm(NULL, array(), t('Delete @language translation', array(
    '@language' => $language
      ->getName(),
  )));
  $entity = entity_load($this->entityTypeId, $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);
}