function ConfigTargetTest::testNested

Same name in this branch
  1. 10 core/modules/system/tests/src/Functional/Form/ConfigTargetTest.php \Drupal\Tests\system\Functional\Form\ConfigTargetTest::testNested()
Same name in other branches
  1. 11.x core/modules/system/tests/src/FunctionalJavascript/Form/ConfigTargetTest.php \Drupal\Tests\system\FunctionalJavascript\Form\ConfigTargetTest::testNested()
  2. 11.x core/modules/system/tests/src/Functional/Form/ConfigTargetTest.php \Drupal\Tests\system\Functional\Form\ConfigTargetTest::testNested()

Tests #config_target with callbacks.

If a #config_target has closures as callbacks, form cache will be disabled.

File

core/modules/system/tests/src/FunctionalJavascript/Form/ConfigTargetTest.php, line 61

Class

ConfigTargetTest
Tests forms using #config_target and #ajax together.

Namespace

Drupal\Tests\system\FunctionalJavascript\Form

Code

public function testNested() : void {
    
    /** @var \Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface $key_value_expirable */
    $key_value_expirable = \Drupal::service('keyvalue.expirable')->get('form');
    $page = $this->getSession()
        ->getPage();
    $assert_session = $this->assertSession();
    $this->drupalGet('/form-test/nested-config-target');
    $this->assertCount(0, $key_value_expirable->getAll());
    $page->fillField('First choice', 'Apple');
    $page->fillField('Second choice', 'Kiwi');
    $assert_session->pageTextNotContains('Option 3');
    $page->selectFieldOption('test1', 'Option 2');
    $assert_session->waitForText('Option 3');
    $assert_session->pageTextContains('Option 3');
    $this->assertCount(0, $key_value_expirable->getAll());
    $page->pressButton('Save configuration');
    $assert_session->statusMessageContains('The configuration options have been saved.', 'status');
    $assert_session->fieldValueEquals('First choice', 'Apple');
    $assert_session->fieldValueEquals('Second choice', 'Kiwi');
    $this->assertCount(0, $key_value_expirable->getAll());
}

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