$message=t('#default_value is %default_value #return_value is %return_value.',array('%default_value'=>var_export($default_value,TRUE),'%return_value'=>var_export($return_value,TRUE)));
* Definition of Drupal\system\Tests\Form\ElementsLabelsTest.
*/
namespaceDrupal\system\Tests\Form;
useDrupal\simpletest\WebTestBase;
/**
* Test form element labels, required markers and associated output.
*/
classElementsLabelsTestextendsWebTestBase{
publicstaticfunctiongetInfo(){
returnarray(
'name'=>'Form element and label output test',
'description'=>'Test form element labels, required markers and associated output.',
'group'=>'Form API',
);
}
functionsetUp(){
parent::setUp('form_test');
}
/**
* Test form elements, labels, title attibutes and required marks output
* correctly and have the correct label option class if needed.
*/
functiontestFormLabels(){
$this->drupalGet('form_test/form-labels');
// Check that the checkbox/radio processing is not interfering with
// basic placement.
$elements=$this->xpath('//input[@id="edit-form-checkboxes-test-third-checkbox"]/following-sibling::label[@for="edit-form-checkboxes-test-third-checkbox" and @class="option"]');
$this->assertTrue(isset($elements[0]),t("Label follows field and label option class correct for regular checkboxes."));
// Make sure the label is rendered for checkboxes.
$elements=$this->xpath('//input[@id="edit-form-checkboxes-test-0"]/following-sibling::label[@for="edit-form-checkboxes-test-0" and @class="option"]');
$this->assertTrue(isset($elements[0]),t("Label 0 found checkbox."));
$elements=$this->xpath('//input[@id="edit-form-radios-test-second-radio"]/following-sibling::label[@for="edit-form-radios-test-second-radio" and @class="option"]');
$this->assertTrue(isset($elements[0]),t("Label follows field and label option class correct for regular radios."));
// Make sure the label is rendered for radios.
$elements=$this->xpath('//input[@id="edit-form-radios-test-0"]/following-sibling::label[@for="edit-form-radios-test-0" and @class="option"]');
$this->assertTrue(isset($elements[0]),t("Label 0 found radios."));
// Exercise various defaults for checkboxes and modifications to ensure
// appropriate override and correct behavior.
$elements=$this->xpath('//input[@id="edit-form-checkbox-test"]/following-sibling::label[@for="edit-form-checkbox-test" and @class="option"]');
$this->assertTrue(isset($elements[0]),t("Label follows field and label option class correct for a checkbox by default."));
// Exercise various defaults for textboxes and modifications to ensure
$this->assertTrue(isset($elements[0]),t("Label tag with required marker precedes required textfield with no title."));
$elements=$this->xpath('//input[@id="edit-form-textfield-test-title-invisible"]/preceding-sibling::label[@for="edit-form-textfield-test-title-invisible" and @class="element-invisible"]');
$this->assertTrue(isset($elements[0]),t("Label preceding field and label class is element-invisible."));
$this->assertFalse(isset($elements[0]),t("No required marker on non-required field."));
$elements=$this->xpath('//input[@id="edit-form-textfield-test-title-after"]/following-sibling::label[@for="edit-form-textfield-test-title-after" and @class="option"]');
$this->assertTrue(isset($elements[0]),t("Label after field and label option class correct for text field."));
$this->assertNoFieldByXPath('//th[@class="select-all"]',NULL,t('Do not display a "Select all" checkbox when #multiple is FALSE, even when #js_select is TRUE.'));
}
/**
* Test the whether the option checker gives an error on invalid tableselect values for checkboxes.