public function DateRepeatFormTestCase::createDateField in Date 7.2
Same name and namespace in other branches
- 7.3 date_repeat/tests/date_repeat_form.test \DateRepeatFormTestCase::createDateField()
Test date field creation.
1 call to DateRepeatFormTestCase::createDateField()
- DateRepeatFormTestCase::testDateRepeatForm in date_repeat/
tests/ date_repeat_form.test - Test the Date Repeat form.
File
- date_repeat/
tests/ date_repeat_form.test, line 502 - Test Date Repeat form.
Class
- DateRepeatFormTestCase
- Test Date Repeat form.
Code
public function createDateField($type, $widget, $display_all_day = FALSE) {
$edit = array();
$edit['fields[_add_new_field][label]'] = 'Test';
$edit['fields[_add_new_field][field_name]'] = 'test';
$edit['fields[_add_new_field][weight]'] = '-100';
$edit['fields[_add_new_field][type]'] = $type;
$edit['fields[_add_new_field][widget_type]'] = $widget;
$label = $edit['fields[_add_new_field][label]'];
$field_edit = array();
$field_edit['field[settings][repeat]'] = 1;
$instance_edit = array();
switch ($widget) {
case 'select':
case 'popup':
$instance_edit['instance[widget][settings][year_range][years_back]'] = '-5';
$instance_edit['instance[widget][settings][year_range][years_forward]'] = '+5';
break;
}
if ($display_all_day) {
$instance_edit['instance[widget][settings][display_all_day]'] = TRUE;
}
// First step : 'Add new field' on the 'Manage fields' page.
$this
->drupalPost('admin/structure/types/manage/date/fields', $edit, t('Save'));
$this
->assertRaw(t('These settings apply to the %label field everywhere it is used.', array(
'%label' => $label,
)), t('Field settings page was displayed.'));
// Second step : 'Field settings' form.
$this
->drupalPost(NULL, $field_edit, t('Save field settings'));
$this
->assertRaw(t('Updated field %label field settings.', array(
'%label' => $label,
)), t('Redirected to instance and widget settings page.'));
// Third step : 'Instance settings' form.
$this
->drupalPost(NULL, $instance_edit, t('Save settings'));
$this
->assertRaw(t('Saved %label configuration.', array(
'%label' => $label,
)), t('Redirected to "Manage fields" page.'));
// Check that the field appears in the overview form.
$this
->assertFieldByXPath('//table[@id="field-overview"]//td[1]', $label, t('Field was created and appears in the overview page.'));
}