function CopyFieldValueTest::testCopyFieldValue

Same name in other branches
  1. 11.x core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php \Drupal\Tests\system\FunctionalJavascript\CopyFieldValueTest::testCopyFieldValue()

Tests copy field value JavaScript functionality.

File

core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php, line 31

Class

CopyFieldValueTest
Tests copy field value functionality.

Namespace

Drupal\Tests\system\FunctionalJavascript

Code

public function testCopyFieldValue() : void {
    $this->drupalGet('/system-test/copy-field-value-test-form');
    $page = $this->getSession()
        ->getPage();
    $source_field_selector = 'edit-source-field';
    $target_field = $page->find('css', '#edit-target-field');
    $random_string = $this->randomString();
    // Ensure that after source field has been filled, target field is filled
    // with the same value.
    $page->fillField($source_field_selector, $random_string);
    $target_field->focus();
    $this->assertEquals($target_field->getValue(), $random_string);
    // Ensure that the target value doesn't change after it has been focused.
    $page->fillField($source_field_selector, '');
    $target_field->focus();
    $this->assertEquals($target_field->getValue(), $random_string);
}

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