Commit 9d8dd3f9 authored by jhodgdon's avatar jhodgdon

Issue #1797318 by Lars Toomre, xjm, dcam: Remove t() from test assert messages in form tests

parent e5a5633f
......@@ -43,6 +43,6 @@ function testExecutionOrder() {
'system_form_form_test_alter_form_alter() executed.',
);
$content = preg_replace('/\s+/', ' ', filter_xss($this->content, array()));
$this->assert(strpos($content, implode(' ', $expected)) !== FALSE, t('Form alter hooks executed in the expected order.'));
$this->assert(strpos($content, implode(' ', $expected)) !== FALSE, 'Form alter hooks executed in the expected order.');
}
}
......@@ -58,7 +58,7 @@ function testFormCheckbox() {
$checked = ($default_value === '1foobar');
}
$checked_in_html = strpos($form, 'checked') !== FALSE;
$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)));
$message = format_string('#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)));
$this->assertIdentical($checked, $checked_in_html, $message);
}
}
......@@ -66,12 +66,12 @@ function testFormCheckbox() {
// Ensure that $form_state['values'] is populated correctly for a checkboxes
// group that includes a 0-indexed array of options.
$results = json_decode($this->drupalPost('form-test/checkboxes-zero', array(), 'Save'));
$this->assertIdentical($results->checkbox_off, array(0, 0, 0), t('All three in checkbox_off are zeroes: off.'));
$this->assertIdentical($results->checkbox_zero_default, array('0', 0, 0), t('The first choice is on in checkbox_zero_default'));
$this->assertIdentical($results->checkbox_string_zero_default, array('0', 0, 0), t('The first choice is on in checkbox_string_zero_default'));
$this->assertIdentical($results->checkbox_off, array(0, 0, 0), 'All three in checkbox_off are zeroes: off.');
$this->assertIdentical($results->checkbox_zero_default, array('0', 0, 0), 'The first choice is on in checkbox_zero_default');
$this->assertIdentical($results->checkbox_string_zero_default, array('0', 0, 0), 'The first choice is on in checkbox_string_zero_default');
$edit = array('checkbox_off[0]' => '0');
$results = json_decode($this->drupalPost('form-test/checkboxes-zero', $edit, 'Save'));
$this->assertIdentical($results->checkbox_off, array('0', 0, 0), t('The first choice is on in checkbox_off but the rest is not'));
$this->assertIdentical($results->checkbox_off, array('0', 0, 0), 'The first choice is on in checkbox_off but the rest is not');
// Ensure that each checkbox is rendered correctly for a checkboxes group
// that includes a 0-indexed array of options.
......@@ -80,7 +80,7 @@ function testFormCheckbox() {
foreach ($checkboxes as $checkbox) {
$checked = isset($checkbox['checked']);
$name = (string) $checkbox['name'];
$this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', t('Checkbox %name correctly checked', array('%name' => $name)));
$this->assertIdentical($checked, $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', array('%name' => $name)));
}
$edit = array('checkbox_off[0]' => '0');
$this->drupalPost('form-test/checkboxes-zero/0', $edit, 'Save');
......@@ -88,7 +88,7 @@ function testFormCheckbox() {
foreach ($checkboxes as $checkbox) {
$checked = isset($checkbox['checked']);
$name = (string) $checkbox['name'];
$this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', t('Checkbox %name correctly checked', array('%name' => $name)));
$this->assertIdentical($checked, $name == 'checkbox_off[0]' || $name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', format_string('Checkbox %name correctly checked', array('%name' => $name)));
}
}
}
......@@ -41,7 +41,7 @@ function testPlaceHolderText() {
':id' => 'edit-' . $type,
':expected' => $expected,
));
$this->assertTrue(!empty($element), t('Placeholder text placed in @type.', array('@type' => $type)));
$this->assertTrue(!empty($element), format_string('Placeholder text placed in @type.', array('@type' => $type)));
}
// Test to make sure textarea has the proper placeholder text.
......@@ -49,7 +49,7 @@ function testPlaceHolderText() {
':id' => 'edit-textarea',
':expected' => $expected,
));
$this->assertTrue(!empty($element), t('Placeholder text placed in textarea.'));
$this->assertTrue(!empty($element), 'Placeholder text placed in textarea.');
}
/**
......@@ -87,7 +87,7 @@ function testOptions() {
':id' => 'edit-' . $type . '-foo',
':class' => 'description',
));
$this->assertTrue(count($elements), t('Custom %type option description found.', array(
$this->assertTrue(count($elements), format_string('Custom %type option description found.', array(
'%type' => $type,
)));
}
......
......@@ -39,57 +39,57 @@ function testFormLabels() {
// 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."));
$this->assertTrue(isset($elements[0]), '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."));
$this->assertTrue(isset($elements[0]), '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."));
$this->assertTrue(isset($elements[0]), '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."));
$this->assertTrue(isset($elements[0]), '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."));
$this->assertTrue(isset($elements[0]), 'Label follows field and label option class correct for a checkbox by default.');
// Exercise various defaults for textboxes and modifications to ensure
// appropriate override and correct behavior.
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-and-required"]/child::abbr[@class="form-required"]/parent::*/following-sibling::input[@id="edit-form-textfield-test-title-and-required"]');
$this->assertTrue(isset($elements[0]), t("Label precedes textfield, with required marker inside label."));
$this->assertTrue(isset($elements[0]), 'Label precedes textfield, with required marker inside label.');
$elements = $this->xpath('//input[@id="edit-form-textfield-test-no-title-required"]/preceding-sibling::label[@for="edit-form-textfield-test-no-title-required"]/abbr[@class="form-required"]');
$this->assertTrue(isset($elements[0]), t("Label tag with required marker precedes required textfield with no title."));
$this->assertTrue(isset($elements[0]), '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->assertTrue(isset($elements[0]), 'Label preceding field and label class is element-invisible.');
$elements = $this->xpath('//input[@id="edit-form-textfield-test-title"]/preceding-sibling::abbr[@class="form-required"]');
$this->assertFalse(isset($elements[0]), t("No required marker on non-required field."));
$this->assertFalse(isset($elements[0]), '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->assertTrue(isset($elements[0]), 'Label after field and label option class correct for text field.');
$elements = $this->xpath('//label[@for="edit-form-textfield-test-title-no-show"]');
$this->assertFalse(isset($elements[0]), t("No label tag when title set not to display."));
$this->assertFalse(isset($elements[0]), 'No label tag when title set not to display.');
// Check #field_prefix and #field_suffix placement.
$elements = $this->xpath('//span[@class="field-prefix"]/following-sibling::div[@id="edit-form-radios-test"]');
$this->assertTrue(isset($elements[0]), t("Properly placed the #field_prefix element after the label and before the field."));
$this->assertTrue(isset($elements[0]), 'Properly placed the #field_prefix element after the label and before the field.');
$elements = $this->xpath('//span[@class="field-suffix"]/preceding-sibling::div[@id="edit-form-radios-test"]');
$this->assertTrue(isset($elements[0]), t("Properly places the #field_suffix element immediately after the form field."));
$this->assertTrue(isset($elements[0]), 'Properly places the #field_suffix element immediately after the form field.');
// Check #prefix and #suffix placement.
$elements = $this->xpath('//div[@id="form-test-textfield-title-prefix"]/following-sibling::div[contains(@class, \'form-item-form-textfield-test-title\')]');
$this->assertTrue(isset($elements[0]), t("Properly places the #prefix element before the form item."));
$this->assertTrue(isset($elements[0]), 'Properly places the #prefix element before the form item.');
$elements = $this->xpath('//div[@id="form-test-textfield-title-suffix"]/preceding-sibling::div[contains(@class, \'form-item-form-textfield-test-title\')]');
$this->assertTrue(isset($elements[0]), t("Properly places the #suffix element before the form item."));
$this->assertTrue(isset($elements[0]), 'Properly places the #suffix element before the form item.');
// Check title attribute for radios and checkboxes.
$elements = $this->xpath('//div[@id="edit-form-checkboxes-title-attribute"]');
......
......@@ -36,14 +36,14 @@ function testMultipleTrue() {
$this->drupalGet('form_test/tableselect/multiple-true');
$this->assertNoText(t('Empty text.'), t('Empty text should not be displayed.'));
$this->assertNoText(t('Empty text.'), 'Empty text should not be displayed.');
// Test for the presence of the Select all rows tableheader.
$this->assertFieldByXPath('//th[@class="select-all"]', NULL, t('Presence of the "Select all" checkbox.'));
$this->assertFieldByXPath('//th[@class="select-all"]', NULL, 'Presence of the "Select all" checkbox.');
$rows = array('row1', 'row2', 'row3');
foreach ($rows as $row) {
$this->assertFieldByXPath('//input[@type="checkbox"]', $row, t('Checkbox for value @row.', array('@row' => $row)));
$this->assertFieldByXPath('//input[@type="checkbox"]', $row, format_string('Checkbox for value @row.', array('@row' => $row)));
}
}
......@@ -53,14 +53,14 @@ function testMultipleTrue() {
function testMultipleFalse() {
$this->drupalGet('form_test/tableselect/multiple-false');
$this->assertNoText(t('Empty text.'), t('Empty text should not be displayed.'));
$this->assertNoText(t('Empty text.'), 'Empty text should not be displayed.');
// Test for the absence of the Select all rows tableheader.
$this->assertNoFieldByXPath('//th[@class="select-all"]', '', t('Absence of the "Select all" checkbox.'));
$this->assertNoFieldByXPath('//th[@class="select-all"]', '', 'Absence of the "Select all" checkbox.');
$rows = array('row1', 'row2', 'row3');
foreach ($rows as $row) {
$this->assertFieldByXPath('//input[@type="radio"]', $row, t('Radio button for value @row.', array('@row' => $row)));
$this->assertFieldByXPath('//input[@type="radio"]', $row, format_string('Radio button for value @row.', array('@row' => $row)));
}
}
......@@ -94,7 +94,7 @@ function testTableselectColSpan() {
*/
function testEmptyText() {
$this->drupalGet('form_test/tableselect/empty-text');
$this->assertText(t('Empty text.'), t('Empty text should be displayed.'));
$this->assertText(t('Empty text.'), 'Empty text should be displayed.');
}
/**
......@@ -107,18 +107,18 @@ function testMultipleTrueSubmit() {
$edit['tableselect[row1]'] = TRUE;
$this->drupalPost('form_test/tableselect/multiple-true', $edit, 'Submit');
$this->assertText(t('Submitted: row1 = row1'), t('Checked checkbox row1'));
$this->assertText(t('Submitted: row2 = 0'), t('Unchecked checkbox row2.'));
$this->assertText(t('Submitted: row3 = 0'), t('Unchecked checkbox row3.'));
$this->assertText(t('Submitted: row1 = row1'), 'Checked checkbox row1');
$this->assertText(t('Submitted: row2 = 0'), 'Unchecked checkbox row2.');
$this->assertText(t('Submitted: row3 = 0'), 'Unchecked checkbox row3.');
// Test a submission with multiple checkboxes checked.
$edit['tableselect[row1]'] = TRUE;
$edit['tableselect[row3]'] = TRUE;
$this->drupalPost('form_test/tableselect/multiple-true', $edit, 'Submit');
$this->assertText(t('Submitted: row1 = row1'), t('Checked checkbox row1.'));
$this->assertText(t('Submitted: row2 = 0'), t('Unchecked checkbox row2.'));
$this->assertText(t('Submitted: row3 = row3'), t('Checked checkbox row3.'));
$this->assertText(t('Submitted: row1 = row1'), 'Checked checkbox row1.');
$this->assertText(t('Submitted: row2 = 0'), 'Unchecked checkbox row2.');
$this->assertText(t('Submitted: row3 = row3'), 'Checked checkbox row3.');
}
......@@ -128,7 +128,7 @@ function testMultipleTrueSubmit() {
function testMultipleFalseSubmit() {
$edit['tableselect'] = 'row1';
$this->drupalPost('form_test/tableselect/multiple-false', $edit, 'Submit');
$this->assertText(t('Submitted: row1'), t('Selected radio button'));
$this->assertText(t('Submitted: row1'), 'Selected radio button');
}
/**
......@@ -137,18 +137,18 @@ function testMultipleFalseSubmit() {
function testAdvancedSelect() {
// When #multiple = TRUE a Select all checkbox should be displayed by default.
$this->drupalGet('form_test/tableselect/advanced-select/multiple-true-default');
$this->assertFieldByXPath('//th[@class="select-all"]', NULL, t('Display a "Select all" checkbox by default when #multiple is TRUE.'));
$this->assertFieldByXPath('//th[@class="select-all"]', NULL, 'Display a "Select all" checkbox by default when #multiple is TRUE.');
// When #js_select is set to FALSE, a "Select all" checkbox should not be displayed.
$this->drupalGet('form_test/tableselect/advanced-select/multiple-true-no-advanced-select');
$this->assertNoFieldByXPath('//th[@class="select-all"]', NULL, t('Do not display a "Select all" checkbox when #js_select is FALSE.'));
$this->assertNoFieldByXPath('//th[@class="select-all"]', NULL, 'Do not display a "Select all" checkbox when #js_select is FALSE.');
// A "Select all" checkbox never makes sense when #multiple = FALSE, regardless of the value of #js_select.
$this->drupalGet('form_test/tableselect/advanced-select/multiple-false-default');
$this->assertNoFieldByXPath('//th[@class="select-all"]', NULL, t('Do not display a "Select all" checkbox when #multiple is FALSE.'));
$this->assertNoFieldByXPath('//th[@class="select-all"]', NULL, 'Do not display a "Select all" checkbox when #multiple is FALSE.');
$this->drupalGet('form_test/tableselect/advanced-select/multiple-false-advanced-select');
$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.'));
$this->assertNoFieldByXPath('//th[@class="select-all"]', NULL, 'Do not display a "Select all" checkbox when #multiple is FALSE, even when #js_select is TRUE.');
}
......@@ -167,11 +167,11 @@ function testMultipleTrueOptionchecker() {
// Test with a valid value.
list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array('tableselect' => array('row1' => 'row1')));
$this->assertFalse(isset($errors['tableselect']), t('Option checker allows valid values for checkboxes.'));
$this->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for checkboxes.');
// Test with an invalid value.
list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array('tableselect' => array('non_existing_value' => 'non_existing_value')));
$this->assertTrue(isset($errors['tableselect']), t('Option checker disallows invalid values for checkboxes.'));
$this->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for checkboxes.');
}
......@@ -192,11 +192,11 @@ function testMultipleFalseOptionchecker() {
// Test with a valid value.
list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array('tableselect' => 'row1'));
$this->assertFalse(isset($errors['tableselect']), t('Option checker allows valid values for radio buttons.'));
$this->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for radio buttons.');
// Test with an invalid value.
list($processed_form, $form_state, $errors) = $this->formSubmitHelper($form, array('tableselect' => 'non_existing_value'));
$this->assertTrue(isset($errors['tableselect']), t('Option checker disallows invalid values for radio buttons.'));
$this->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for radio buttons.');
}
......
......@@ -46,7 +46,7 @@ function testJavaScriptOrdering() {
$this->drupalGet('form_test/vertical-tabs');
$position1 = strpos($this->content, 'core/misc/vertical-tabs.js');
$position2 = strpos($this->content, 'core/misc/collapse.js');
$this->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, t('vertical-tabs.js is included before collapse.js'));
$this->assertTrue($position1 !== FALSE && $position2 !== FALSE && $position1 < $position2, 'vertical-tabs.js is included before collapse.js');
}
/**
......
......@@ -268,7 +268,7 @@ function testCheckboxProcessing() {
// First, try to submit without the required checkbox.
$edit = array();
$this->drupalPost('form-test/checkbox', $edit, t('Submit'));
$this->assertRaw(t('!name field is required.', array('!name' => 'required_checkbox')), t('A required checkbox is actually mandatory'));
$this->assertRaw(t('!name field is required.', array('!name' => 'required_checkbox')), 'A required checkbox is actually mandatory');
// Now try to submit the form correctly.
$values = drupal_json_decode($this->drupalPost(NULL, array('required_checkbox' => 1), t('Submit')));
......@@ -281,7 +281,7 @@ function testCheckboxProcessing() {
'zero_checkbox_off' => '',
);
foreach ($expected_values as $widget => $expected_value) {
$this->assertEqual($values[$widget], $expected_value, t('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
$this->assertEqual($values[$widget], $expected_value, format_string('Checkbox %widget returns expected value (expected: %expected, got: %value)', array(
'%widget' => var_export($widget, TRUE),
'%expected' => var_export($expected_value, TRUE),
'%value' => var_export($values[$widget], TRUE),
......@@ -345,7 +345,7 @@ function testSelect() {
'multiple_no_default_required' => array('three' => 'three'),
);
foreach ($expected as $key => $value) {
$this->assertIdentical($values[$key], $value, t('@name: @actual is equal to @expected.', array(
$this->assertIdentical($values[$key], $value, format_string('@name: @actual is equal to @expected.', array(
'@name' => $key,
'@actual' => var_export($values[$key], TRUE),
'@expected' => var_export($value, TRUE),
......@@ -539,7 +539,7 @@ function assertFormValuesDefault($values, $form) {
// Checkboxes values are not filtered out.
$values[$key] = array_filter($values[$key]);
}
$this->assertIdentical($expected_value, $values[$key], t('Default value for %type: expected %expected, returned %returned.', array('%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE))));
$this->assertIdentical($expected_value, $values[$key], format_string('Default value for %type: expected %expected, returned %returned.', array('%type' => $key, '%expected' => var_export($expected_value, TRUE), '%returned' => var_export($values[$key], TRUE))));
}
// Recurse children.
......@@ -590,7 +590,7 @@ function testDisabledMarkup() {
':div-class' => $class,
':value' => isset($item['#value']) ? $item['#value'] : '',
));
$this->assertTrue(isset($element[0]), t('Disabled form element class found for #type %type.', array('%type' => $item['#type'])));
$this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => $item['#type'])));
}
// Verify special element #type text-format.
......@@ -598,12 +598,12 @@ function testDisabledMarkup() {
':name' => 'text_format[value]',
':div-class' => 'form-disabled',
));
$this->assertTrue(isset($element[0]), t('Disabled form element class found for #type %type.', array('%type' => 'text_format[value]')));
$this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => 'text_format[value]')));
$element = $this->xpath('//div[contains(@class, :div-class)]/descendant::select[@name=:name]', array(
':name' => 'text_format[format]',
':div-class' => 'form-disabled',
));
$this->assertTrue(isset($element[0]), t('Disabled form element class found for #type %type.', array('%type' => 'text_format[format]')));
$this->assertTrue(isset($element[0]), format_string('Disabled form element class found for #type %type.', array('%type' => 'text_format[format]')));
}
/**
......@@ -616,7 +616,7 @@ function testInputForgery() {
$checkbox = $this->xpath('//input[@name="checkboxes[two]"]');
$checkbox[0]['value'] = 'FORGERY';
$this->drupalPost(NULL, array('checkboxes[one]' => TRUE, 'checkboxes[two]' => TRUE), t('Submit'));
$this->assertText('An illegal choice has been detected.', t('Input forgery was detected.'));
$this->assertText('An illegal choice has been detected.', 'Input forgery was detected.');
}
/**
......@@ -631,7 +631,7 @@ function testRequiredAttribute() {
':id' => 'edit-' . $type,
':expected' => $expected,
));
$this->assertTrue(!empty($element), t('The @type has the proper required attribute.', array('@type' => $type)));
$this->assertTrue(!empty($element), format_string('The @type has the proper required attribute.', array('@type' => $type)));
}
// Test to make sure textarea has the proper required attribute.
......@@ -639,6 +639,6 @@ function testRequiredAttribute() {
':id' => 'edit-textarea',
':expected' => $expected,
));
$this->assertTrue(!empty($element), t('The textarea has the proper required attribute.'));
$this->assertTrue(!empty($element), 'The textarea has the proper required attribute.');
}
}
......@@ -54,7 +54,7 @@ function testLanguageSelectElementOptions() {
'edit-languages-locked' => LANGUAGE_LOCKED,
'edit-languages-config-and-locked' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED);
foreach ($ids as $id => $flags) {
$this->assertField($id, t('The @id field was found on the page.', array('@id' => $id)));
$this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id)));
$options = array();
foreach (language_list($flags) as $langcode => $language) {
$options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
......@@ -63,7 +63,7 @@ function testLanguageSelectElementOptions() {
}
// Test that the #options were not altered by #languages.
$this->assertField('edit-language-custom-options', t('The @id field was found on the page.', array('@id' => 'edit-language-custom-options')));
$this->assertField('edit-language-custom-options', format_string('The @id field was found on the page.', array('@id' => 'edit-language-custom-options')));
$this->_testLanguageSelectElementOptions('edit-language-custom-options', array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'));
}
......@@ -80,7 +80,7 @@ function testHiddenLanguageSelectElement() {
// Check that the language fields were rendered on the page.
$ids = array('edit-languages-all', 'edit-languages-configurable', 'edit-languages-locked', 'edit-languages-config-and-locked');
foreach ($ids as $id) {
$this->assertNoField($id, t('The @id field was not found on the page.', array('@id' => $id)));
$this->assertNoField($id, format_string('The @id field was not found on the page.', array('@id' => $id)));
}
// Check that the submitted values were the default values of the language
......@@ -115,6 +115,6 @@ protected function _testLanguageSelectElementOptions($id, $options) {
$this->assertEqual((string) $option, $option_title);
next($options);
}
$this->assertEqual($count, count($options), t('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', array('@languages' => count($options), '@number' => $count)));
$this->assertEqual($count, count($options), format_string('The number of languages and the number of options shown by the language element are the same: @languages languages, @number options', array('@languages' => count($options), '@number' => $count)));
}
}
......@@ -87,7 +87,7 @@ private function submitForm($values, $valid_input) {
'%values' => print_r($values, TRUE),
'%errors' => $valid_form ? t('None') : implode(' ', $errors),
);
$this->assertTrue($valid_input == $valid_form, t('Input values: %values<br/>Validation handler errors: %errors', $args));
$this->assertTrue($valid_input == $valid_form, format_string('Input values: %values<br/>Validation handler errors: %errors', $args));
// We check submitted values only if we have a valid input.
if ($valid_input) {
......@@ -95,7 +95,7 @@ private function submitForm($values, $valid_input) {
// submission handler was properly executed.
$stored_values = $form_state['storage']['programmatic_form_submit'];
foreach ($values as $key => $value) {
$this->assertTrue(isset($stored_values[$key]) && $stored_values[$key] == $value, t('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
$this->assertTrue(isset($stored_values[$key]) && $stored_values[$key] == $value, format_string('Submission handler correctly executed: %stored_key is %stored_value', array('%stored_key' => $key, '%stored_value' => print_r($value, TRUE))));
}
}
}
......
......@@ -52,14 +52,14 @@ function testRebuildPreservesValues() {
$this->drupalPost('form-test/form-rebuild-preserve-values', $edit, 'Add more');
// Verify that initial elements retained their submitted values.
$this->assertFieldChecked('edit-checkbox-1-default-off', t('A submitted checked checkbox retained its checked state during a rebuild.'));
$this->assertNoFieldChecked('edit-checkbox-1-default-on', t('A submitted unchecked checkbox retained its unchecked state during a rebuild.'));
$this->assertFieldById('edit-text-1', 'foo', t('A textfield retained its submitted value during a rebuild.'));
$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', t('A newly added checkbox was initialized with a default checked state.'));
$this->assertNoFieldChecked('edit-checkbox-2-default-off', t('A newly added checkbox was initialized with a default unchecked state.'));
$this->assertFieldById('edit-text-2', 'DEFAULT 2', t('A newly added textfield was initialized with its default value.'));
$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.');
}
/**
......@@ -93,7 +93,7 @@ function testPreserveFormActionAfterAJAX() {
// field items in the field for which we just added an item.
$this->drupalGet('node/add/page');
$this->drupalPostAJAX(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), 'system/ajax', array(), array(), 'page-node-form');
$this->assert(count($this->xpath('//div[contains(@class, "field-name-field-ajax-test")]//input[@type="text"]')) == 2, t('AJAX submission succeeded.'));
$this->assert(count($this->xpath('//div[contains(@class, "field-name-field-ajax-test")]//input[@type="text"]')) == 2, 'AJAX submission succeeded.');
// Submit the form with the non-Ajax "Save" button, leaving the title field
// blank to trigger a validation error, and ensure that a validation error
......@@ -101,14 +101,14 @@ function testPreserveFormActionAfterAJAX() {
// re-rendered without being re-built, which is what happens when there's
// a validation error.
$this->drupalPost(NULL, array(), t('Save'));
$this->assertText('Title field is required.', t('Non-AJAX submission correctly triggered a validation error.'));
$this->assertText('Title field is required.', 'Non-AJAX submission correctly triggered a validation error.');
// Ensure that the form contains two items in the multi-valued field, so we
// know we're testing a form that was correctly retrieved from cache.
$this->assert(count($this->xpath('//form[contains(@id, "page-node-form")]//div[contains(@class, "form-item-field-ajax-test")]//input[@type="text"]')) == 2, t('Form retained its state from cache.'));
$this->assert(count($this->xpath('//form[contains(@id, "page-node-form")]//div[contains(@class, "form-item-field-ajax-test")]//input[@type="text"]')) == 2, 'Form retained its state from cache.');
// Ensure that the form's action is correct.
$forms = $this->xpath('//form[contains(@class, "node-page-form")]');
$this->assert(count($forms) == 1 && $forms[0]['action'] == url('node/add/page'), t('Re-rendered form contains the correct action value.'));
$this->assert(count($forms) == 1 && $forms[0]['action'] == url('node/add/page'), 'Re-rendered form contains the correct action value.');
}
}
......@@ -44,7 +44,7 @@ function testFormStateValuesCleanAdvanced() {
$this->image = current($image_files);
// Check if the physical file is there.
$this->assertTrue(is_file($this->image->uri), t("The image file we're going to upload exists."));
$this->assertTrue(is_file($this->image->uri), "The image file we're going to upload exists.");
// "Browse" for the desired file.
$edit = array('files[image]' => drupal_realpath($this->image->uri));
......@@ -53,7 +53,7 @@ function testFormStateValuesCleanAdvanced() {
$this->drupalPost('form_test/form-state-values-clean-advanced', $edit, t('Submit'));
// Expecting a 200 HTTP code.
$this->assertResponse(200, t('Received a 200 response for posted test file.'));
$this->assertRaw(t('You WIN!'), t('Found the success message.'));
$this->assertResponse(200, 'Received a 200 response for posted test file.');
$this->assertRaw(t('You WIN!'), 'Found the success message.');
}
}
......@@ -42,21 +42,21 @@ function testFormStateValuesClean() {
);
// Verify that all internal Form API elements were removed.
$this->assertFalse(isset($values['form_id']), t('%element was removed.', array('%element' => 'form_id')));
$this->assertFalse(isset($values['form_token']), t('%element was removed.', array('%element' => 'form_token')));
$this->assertFalse(isset($values['form_build_id']), t('%element was removed.', array('%element' => 'form_build_id')));
$this->assertFalse(isset($values['op']), t('%element was removed.', array('%element' => 'op')));
$this->assertFalse(isset($values['form_id']), format_string('%element was removed.', array('%element' => 'form_id')));
$this->assertFalse(isset($values['form_token']), format_string('%element was removed.', array('%element' => 'form_token')));
$this->assertFalse(isset($values['form_build_id']), format_string('%element was removed.', array('%element' => 'form_build_id')));
$this->assertFalse(isset($values['op']), format_string('%element was removed.', array('%element' => 'op')));
// Verify that all buttons were removed.
$this->assertFalse(isset($values['foo']), t('%element was removed.', array('%element' => 'foo')));
$this->assertFalse(isset($values['bar']), t('%element was removed.', array('%element' => 'bar')));
$this->assertFalse(isset($values['baz']['foo']), t('%element was removed.', array('%element' => 'foo')));
$this->assertFalse(isset($values['baz']['baz']), t('%element was removed.', array('%element' => 'baz')));
$this->assertFalse(isset($values['foo']), format_string('%element was removed.', array('%element' => 'foo')));
$this->assertFalse(isset($values['bar']), format_string('%element was removed.', array('%element' => 'bar')));
$this->assertFalse(isset($values['baz']['foo']), format_string('%element was removed.', array('%element' => 'foo')));
$this->assertFalse(isset($values['baz']['baz']), format_string('%element was removed.', array('%element' => 'baz')));
// Verify that nested form value still exists.
$this->assertTrue(isset($values['baz']['beer']), t('Nested form value still exists.'));
$this->assertTrue(isset($values['baz']['beer']), 'Nested form value still exists.');
// Verify that actual form values equal resulting form values.
$this->assertEqual($values, $result, t('Expected form values equal actual form values.'));
$this->assertEqual($values, $result, 'Expected form values equal actual form values.');
}
}
......@@ -65,7 +65,7 @@ function testForm() {
$this->drupalPost(NULL, $edit, 'Save');
$this->assertText('Form constructions: 4');
$this->assertText('Title: new', t('The form storage has stored the values.'));
$this->assertText('Title: new', 'The form storage has stored the values.');
}
/**
......@@ -89,7 +89,7 @@ function testFormCached() {
$this->drupalPost(NULL, $edit, 'Save');
$this->assertText('Form constructions: 3');
$this->assertText('Title: new', t('The form storage has stored the values.'));
$this->assertText('Title: new', 'The form storage has stored the values.');
}
/**
......@@ -97,7 +97,7 @@ function testFormCached() {
*/
function testValidation() {
$this->drupalPost('form_test/form-storage', array('title' => '', 'value' => 'value_is_set'), 'Continue submit');
$this->assertPattern('/value_is_set/', t('The input values have been kept.'));
$this->assertPattern('/value_is_set/', 'The input values have been kept.');
}
/**
......
......@@ -43,24 +43,24 @@ function testNoButtonInfoInPost() {
// $form_state['triggering_element'] and the form submit handler not
// running.
$this->drupalPost($path, $edit, NULL, array(), array(), $form_html_id);
$this->assertText('There is no clicked button.', t('$form_state[\'triggering_element\'] set to NULL.'));
$this->assertNoText('Submit handler for form_test_clicked_button executed.', t('Form submit handler did not execute.'));
$this->assertText('There is no clicked button.', '$form_state[\'triggering_element\'] set to NULL.');
$this->assertNoText('Submit handler for form_test_clicked_button executed.', 'Form submit handler did not execute.');
// Ensure submitting a form with one or more submit buttons results in
// $form_state['triggering_element'] being set to the first one the user has
// access to. An argument with 'r' in it indicates a restricted
// (#access=FALSE) button.
$this->drupalPost($path . '/s', $edit, NULL, array(), array(), $form_html_id);
$this->assertText('The clicked button is button1.', t('$form_state[\'triggering_element\'] set to only button.'));
$this->assertText('Submit handler for form_test_clicked_button executed.', t('Form submit handler executed.'));
$this->assertText('The clicked button is button1.', '$form_state[\'triggering_element\'] set to only button.');
$this->assertText('Submit handler for form_test_clicked_button executed.', 'Form submit handler executed.');
$this->drupalPost($path . '/s/s', $edit, NULL, array(), array(), $form_html_id);
$this->assertText('The clicked button is button1.', t('$form_state[\'triggering_element\'] set to first button.'));
$this->assertText('Submit handler for form_test_clicked_button executed.', t('Form submit handler executed.'));