class RebuildTest
Same name in this branch
- 9 core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php \Drupal\Tests\system\FunctionalJavascript\Form\RebuildTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php \Drupal\Tests\system\FunctionalJavascript\Form\RebuildTest
- 11.x core/modules/system/tests/src/Functional/Form/RebuildTest.php \Drupal\Tests\system\Functional\Form\RebuildTest
- 10 core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php \Drupal\Tests\system\FunctionalJavascript\Form\RebuildTest
- 10 core/modules/system/tests/src/Functional/Form/RebuildTest.php \Drupal\Tests\system\Functional\Form\RebuildTest
- 8.9.x core/modules/system/tests/src/FunctionalJavascript/Form/RebuildTest.php \Drupal\Tests\system\FunctionalJavascript\Form\RebuildTest
- 8.9.x core/modules/system/tests/src/Functional/Form/RebuildTest.php \Drupal\Tests\system\Functional\Form\RebuildTest
Tests functionality of \Drupal\Core\Form\FormBuilderInterface::rebuildForm().
@group Form
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Form\RebuildTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of RebuildTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ RebuildTest.php, line 12
Namespace
Drupal\Tests\system\Functional\FormView source
class RebuildTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'node',
'form_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* A user for testing.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
$this->webUser = $this->drupalCreateUser([
'access content',
]);
$this->drupalLogin($this->webUser);
}
/**
* Tests preservation of values.
*/
public function testRebuildPreservesValues() {
$edit = [
'checkbox_1_default_off' => TRUE,
'checkbox_1_default_on' => FALSE,
'text_1' => 'foo',
];
$this->drupalGet('form-test/form-rebuild-preserve-values');
$this->submitForm($edit, 'Add more');
$assert_session = $this->assertSession();
// Verify that initial elements retained their submitted values.
$assert_session->checkboxChecked('edit-checkbox-1-default-off');
$assert_session->checkboxNotChecked('edit-checkbox-1-default-on');
$assert_session->fieldValueEquals('edit-text-1', 'foo');
// Verify that newly added elements were initialized with their default values.
$assert_session->checkboxChecked('edit-checkbox-2-default-on');
$assert_session->checkboxNotChecked('edit-checkbox-2-default-off');
$assert_session->fieldValueEquals('edit-text-2', 'DEFAULT 2');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.