public function RequiredByRoleDateFieldWebTestCase::DotestRequiredRole in Required by role 7
Test for required roles.
@todo Test with blank default value @todo Test with now default value @todo Test with todate null value @todo Test with todate optional value @todo Test with todate required value
1 call to RequiredByRoleDateFieldWebTestCase::DotestRequiredRole()
- RequiredByRoleDateFieldWebTestCase::testDoTests in tests/
required_by_role_test/ RequiredByRoleDateFieldWebTestCase.test - Grouping testing method.
File
- tests/
required_by_role_test/ RequiredByRoleDateFieldWebTestCase.test, line 61 - Tests for the Email field.
Class
- RequiredByRoleDateFieldWebTestCase
- @file Tests for the Email field.
Code
public function DotestRequiredRole() {
$this
->drupalLogin($this
->getRequiredUser());
$edit = array();
$edit['title'] = $this
->randomName(8);
$edit['body[und][0][value]'] = $this
->randomName(16);
$rid = (int) $this->required_fields_rid;
$required_by_role_settings = array(
$rid => $rid,
);
// Create a date fields with simple values.
foreach (array(
'date',
'datestamp',
'datetime',
) as $field_type) {
foreach (array(
'date_select',
'date_popup',
'date_text',
) as $widget_type) {
$field_name = "field_test_{$widget_type}";
$label = 'Test';
$options = array(
'label' => $label,
'widget_type' => $widget_type,
'field_name' => $field_name,
'field_type' => $field_type,
'input_format' => 'm/d/Y - H:i',
'todate' => NULL,
);
$this
->createDateField($options, $required_by_role_settings);
$this
->drupalPost('node/add/' . $this->entity_bundle, $edit, t('Save'));
switch ($widget_type) {
case 'date_select':
$this
->assertText('Month field is required.');
$this
->assertText('Day field is required.');
$this
->assertText('Year field is required.');
$this
->assertText('Hour field is required.');
$this
->assertText('Minute field is required.');
break;
case 'date_text':
case 'date_popup':
$this
->assertText('A valid date is required for ' . $label . ' Start date.');
$this
->assertText('A valid date is required for ' . $label . ' End date.');
break;
}
$this
->deleteDateField($label);
}
}
$this
->drupalLogout();
}