Commit 77b3dbd2 authored by catch's avatar catch

Issue #2943646 by SylvainM: Translated user can not be deleted

parent ed99d34b
......@@ -743,7 +743,7 @@ public function entityFormSourceChange($form, FormStateInterface $form_state) {
* Takes care of entity deletion.
*/
public function entityFormDelete($form, FormStateInterface $form_state) {
$form_object = $form_state->getFormObject()->getEntity();
$form_object = $form_state->getFormObject();
$entity = $form_object->getEntity();
if (count($entity->getTranslationLanguages()) > 1) {
drupal_set_message(t('This will delete all the translations of %label.', ['%label' => $entity->label()]), 'warning');
......
......@@ -75,4 +75,25 @@ protected function doTestTranslationEdit() {
}
}
/**
* Test translated user deletion.
*/
public function testTranslatedUserDeletion() {
$this->drupalLogin($this->administrator);
$entity_id = $this->createEntity($this->getNewEntityValues('en'), 'en');
$entity = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId)
->load($entity_id);
$translated_entity = $entity->addTranslation('fr');
$translated_entity->save();
$url = $entity->toUrl(
'edit-form',
['language' => $this->container->get('language_manager')->getLanguage('en')]
);
$this->drupalPostForm($url, [], t('Cancel account'));
$this->assertSession()->statusCodeEquals(200);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment