function FormsTestCase::testTextfieldStringValue
Tests that submitted values are converted to scalar strings for textfields.
File
-
modules/
simpletest/ tests/ form.test, line 477
Class
- FormsTestCase
- @file Unit tests for the Drupal Form API.
Code
public function testTextfieldStringValue() {
// Check multivalued submissions.
$multivalue = array(
'evil' => 'multivalue',
'not so' => 'good',
);
$this->checkFormValue('textfield', $multivalue, '');
$this->checkFormValue('password', $multivalue, '');
$this->checkFormValue('textarea', $multivalue, '');
$this->checkFormValue('machine_name', $multivalue, '');
$this->checkFormValue('password_confirm', $multivalue, array(
'pass1' => '',
'pass2' => '',
));
// Check integer submissions.
$integer = 5;
$string = '5';
$this->checkFormValue('textfield', $integer, $string);
$this->checkFormValue('password', $integer, $string);
$this->checkFormValue('textarea', $integer, $string);
$this->checkFormValue('machine_name', $integer, $string);
$this->checkFormValue('password_confirm', array(
'pass1' => $integer,
'pass2' => $integer,
), array(
'pass1' => $string,
'pass2' => $string,
));
// Check that invalid array keys are ignored for password confirm elements.
$this->checkFormValue('password_confirm', array(
'pass1' => 'test',
'pass2' => 'test',
'extra' => 'invalid',
), array(
'pass1' => 'test',
'pass2' => 'test',
));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.