function ContentTranslationHandlerTest::providerTestEntityFormSharedElements
Same name in other branches
- 9 core/modules/content_translation/tests/src/Kernel/ContentTranslationHandlerTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationHandlerTest::providerTestEntityFormSharedElements()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationHandlerTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationHandlerTest::providerTestEntityFormSharedElements()
- 11.x core/modules/content_translation/tests/src/Kernel/ContentTranslationHandlerTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationHandlerTest::providerTestEntityFormSharedElements()
Returns test cases for ::testEntityFormSharedElements().
Return value
array[] An array of test cases, each one containing the element to alter, the form state, and the expected altered element.
File
-
core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationHandlerTest.php, line 147
Class
- ContentTranslationHandlerTest
- Tests the content translation handler.
Namespace
Drupal\Tests\content_translation\KernelCode
public function providerTestEntityFormSharedElements() {
$tests = [];
$element = [];
$tests['empty'] = [
'element' => $element,
'default_translation_affected' => TRUE,
'default_translation' => TRUE,
'translation_form' => FALSE,
'is_submitted' => TRUE,
'is_rebuilding' => TRUE,
'expected' => $element,
'display_warning' => FALSE,
];
$element = [
'#type' => 'textfield',
];
$tests['no-children'] = $tests['empty'];
$tests['no-children']['element'] = $element;
$tests['no-children']['expected'] = $element;
$element = [
'test' => [
'#type' => 'textfield',
'#multilingual' => TRUE,
],
];
$tests['multilingual'] = $tests['empty'];
$tests['multilingual']['element'] = $element;
$tests['multilingual']['expected'] = $element;
unset($element['test']['#multilingual']);
$tests['no-title'] = $tests['empty'];
$tests['no-title']['element'] = $element;
$tests['no-title']['expected'] = $element;
$element['test']['#title'] = 'Test';
$tests['no-translatability-clue'] = $tests['empty'];
$tests['no-translatability-clue']['element'] = $element;
$tests['no-translatability-clue']['expected'] = $element;
$expected = $element;
$expected['test']['#title'] .= ' <span class="translation-entity-all-languages">(all languages)</span>';
$tests['translatability-clue'] = $tests['no-translatability-clue'];
$tests['translatability-clue']['default_translation_affected'] = FALSE;
$tests['translatability-clue']['expected'] = $expected;
$ignored_types = [
'actions',
'details',
'hidden',
'link',
'token',
'value',
'vertical_tabs',
];
foreach ($ignored_types as $ignored_type) {
$element = [
'test' => [
'#type' => $ignored_type,
'#title' => 'Test',
],
];
$tests["ignore-{$ignored_type}"] = $tests['translatability-clue'];
$tests["ignore-{$ignored_type}"]['element'] = $element;
$tests["ignore-{$ignored_type}"]['expected'] = $element;
}
$tests['unknown-field'] = $tests['no-translatability-clue'];
$tests['unknown-field']['default_translation'] = FALSE;
$element = [
'name' => [
'#type' => 'textfield',
],
];
$expected = $element;
$expected['name']['#access'] = FALSE;
$tests['hide-untranslatable'] = $tests['unknown-field'];
$tests['hide-untranslatable']['element'] = $element;
$tests['hide-untranslatable']['expected'] = $expected;
$tests['is-rebuilding'] = $tests['hide-untranslatable'];
$tests['is-rebuilding']['is_submitted'] = FALSE;
$tests['display-warning'] = $tests['is-rebuilding'];
$tests['display-warning']['is_rebuilding'] = FALSE;
$tests['display-warning']['display_warning'] = TRUE;
$tests['no-translation-form'] = $tests['no-translatability-clue'];
$tests['no-translation-form']['translation_form'] = FALSE;
return $tests;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.