function ConfigTargetTest::testDuplicateTargetsNotAllowed
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Form/ConfigTargetTest.php \Drupal\Tests\Core\Form\ConfigTargetTest::testDuplicateTargetsNotAllowed()
@covers \Drupal\Core\Form\ConfigFormBase::storeConfigKeyToFormElementMap
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ ConfigTargetTest.php, line 28
Class
- ConfigTargetTest
- @coversDefaultClass \Drupal\Core\Form\ConfigTarget @group Form
Namespace
Drupal\Tests\Core\FormCode
public function testDuplicateTargetsNotAllowed() : void {
$form = [
'test' => [
'#type' => 'text',
'#default_value' => 'A test',
'#config_target' => new ConfigTarget('system.site', 'admin_compact_mode', 'intval', 'boolval'),
'#name' => 'test',
'#array_parents' => [
'test',
],
],
'duplicate' => [
'#type' => 'text',
'#config_target' => new ConfigTarget('system.site', 'admin_compact_mode', 'intval', 'boolval'),
'#name' => 'duplicate',
'#array_parents' => [
'duplicate',
],
],
];
$test_form = new class ($this->prophesize(ConfigFactoryInterface::class)
->reveal(), $this->prophesize(TypedConfigManagerInterface::class)
->reveal()) extends ConfigFormBase {
use RedundantEditableConfigNamesTrait;
public function getFormId() {
return 'test';
}
};
$form_state = new FormState();
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Two #config_targets both target "admin_compact_mode" in the "system.site" config: `$form[\'test\']` and `$form[\'duplicate\']`.');
$test_form->storeConfigKeyToFormElementMap($form, $form_state);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.