function ConfigTargetTest::testFromFormString

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Form/ConfigTargetTest.php \Drupal\Tests\Core\Form\ConfigTargetTest::testFromFormString()

@covers ::fromForm
@covers ::fromString

File

core/tests/Drupal/Tests/Core/Form/ConfigTargetTest.php, line 117

Class

ConfigTargetTest
@coversDefaultClass \Drupal\Core\Form\ConfigTarget[[api-linebreak]] @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testFromFormString() : void {
  $form = [
    'group' => [
      '#type' => 'details',
      'test' => [
        '#type' => 'text',
        '#default_value' => 'A test',
        '#config_target' => 'system.site:name',
        '#name' => 'test',
        '#parents' => [
          'test',
        ],
      ],
    ],
  ];
  $config_target = ConfigTarget::fromForm([
    'group',
    'test',
  ], $form);
  $this->assertSame('system.site', $config_target->configName);
  $this->assertSame([
    'name',
  ], $config_target->propertyPaths);
  $this->assertSame([
    'test',
  ], $config_target->elementParents);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.