You are here

function ContentCrudTestCase::createField in Content Construction Kit (CCK) 6.2

Same name and namespace in other branches
  1. 6.3 tests/content.crud.test \ContentCrudTestCase::createField()
  2. 6 tests/content.crud.test \ContentCrudTestCase::createField()

Creates a field instance with a predictable name. Also makes all future calls to functions which take an optional field use this one as the default.

Parameters

$settings Array to be passed to content_field_instance_create. If the field_name: or type_name keys are missing, then they will be added. The default field name is simpletest_fN, where N is 1 for the first created field, and increments. The default type name is type name of the $content_type argument.

$content_type Either a content type object, or the index of an acquired content type:

Return value

The newly created field instance.

5 calls to ContentCrudTestCase::createField()
ContentCrudTestCase::createFieldText in tests/content.crud.test
Creates a textfield instance. Identical to createField() except it ensures that the text module is enabled, and adds default settings of type (text) and widget_type (text_textfield) if they are not given in $settings. @sa createField()
ContentOptionWidgetTest::testChecboxes in tests/content.crud.test
Multiple (checkboxes), not required:
ContentOptionWidgetTest::testOnOffCheckbox in tests/content.crud.test
On/Off Checkbox, not required:
ContentOptionWidgetTest::testRadios in tests/content.crud.test
Single (radios), not required:
ContentOptionWidgetTest::testSelect in tests/content.crud.test
Single select, not required:

File

tests/content.crud.test, line 288

Class

ContentCrudTestCase
Base class for CCK CRUD tests. Defines many helper functions useful for writing CCK CRUD tests.

Code

function createField($settings, $content_type = 0) {
  if (is_numeric($content_type) && isset($this->content_types[$content_type])) {
    $content_type = $this->content_types[$content_type];
  }
  $defaults = array(
    'field_name' => 'simpletest_f' . $this->next_field_n++,
    'type_name' => $content_type->type,
  );
  $settings = $settings + $defaults;
  $this->last_field = content_field_instance_create($settings);
  return $this->last_field;
}