You are here

function SelectOrOtherTestBase::testCardinalityValidation in Select (or other) 7.3

Make sure field cardinality is checked.

File

tests/SelectOrOtherTestBase.test, line 70
Contains SelectOrOtherTestBase.

Class

SelectOrOtherTestBase
Class SelectOrOtherTestBase Base class for select_or_other testing.

Code

function testCardinalityValidation() {
  $tested_types = array();
  foreach ($this->fields as $field_name => $field) {
    $widget_type = $field['instance_settings']['widget']['type'];
    if (!isset($tested_types[$widget_type])) {
      $field_info = field_info_field($field_name);
      $field_info['cardinality'] = $this->fields[$field_name]['cardinality'] = 2;
      field_update_field($field_info);
      $this
        ->selectAllOptions($field_name);
      $this
        ->assertText('cannot hold more than 2 values');
      $tested_types[$widget_type] = TRUE;
    }
  }
}