function RebuildTest::testRebuildPreservesValues in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Form/RebuildTest.php \Drupal\system\Tests\Form\RebuildTest::testRebuildPreservesValues()
Tests preservation of values.
File
- core/
modules/ system/ src/ Tests/ Form/ RebuildTest.php, line 48 - Contains \Drupal\system\Tests\Form\RebuildTest.
Class
- RebuildTest
- Tests functionality of \Drupal\Core\Form\FormBuilderInterface::rebuildForm().
Namespace
Drupal\system\Tests\FormCode
function testRebuildPreservesValues() {
$edit = array(
'checkbox_1_default_off' => TRUE,
'checkbox_1_default_on' => FALSE,
'text_1' => 'foo',
);
$this
->drupalPostForm('form-test/form-rebuild-preserve-values', $edit, 'Add more');
// Verify that initial elements retained their submitted values.
$this
->assertFieldChecked('edit-checkbox-1-default-off', 'A submitted checked checkbox retained its checked state during a rebuild.');
$this
->assertNoFieldChecked('edit-checkbox-1-default-on', 'A submitted unchecked checkbox retained its unchecked state during a rebuild.');
$this
->assertFieldById('edit-text-1', 'foo', 'A textfield retained its submitted value during a rebuild.');
// Verify that newly added elements were initialized with their default values.
$this
->assertFieldChecked('edit-checkbox-2-default-on', 'A newly added checkbox was initialized with a default checked state.');
$this
->assertNoFieldChecked('edit-checkbox-2-default-off', 'A newly added checkbox was initialized with a default unchecked state.');
$this
->assertFieldById('edit-text-2', 'DEFAULT 2', 'A newly added textfield was initialized with its default value.');
}