| 7 form.test | FormsFormStorageTestCase::testForm() |
| 8 form.test | FormsFormStorageTestCase::testForm() |
Tests using the form in a usual way.
File
- modules/
simpletest/ tests/ form.test, line 975 - Unit tests for the Drupal Form API.
Code
function testForm() {
$this->drupalGet('form_test/form-storage');
$this->assertText('Form constructions: 1');
$edit = array(
'title' => 'new',
'value' => 'value_is_set',
);
// Use form rebuilding triggered by a submit button.
$this->drupalPost(NULL, $edit, 'Continue submit');
$this->assertText('Form constructions: 2');
$this->assertText('Form constructions: 3');
// Reset the form to the values of the storage, using a form rebuild
// triggered by button of type button.
$this->drupalPost(NULL, array('title' => 'changed'), 'Reset');
$this->assertFieldByName('title', 'new', 'Values have been resetted.');
// After rebuilding, the form has been cached.
$this->assertText('Form constructions: 4');
$this->drupalPost(NULL, $edit, 'Save');
$this->assertText('Form constructions: 4');
$this->assertText('Title: new', t('The form storage has stored the values.'));
}
Login or register to post comments