You are here

function ContentMigrateTestCase::setupField in Content Construction Kit (CCK) 7.3

Setup a field definition array based on parameters.

Parameters

$type the field type.:

$widget the widget type.:

$multiple an integer referring to the field setting of that name.:

$required should the field be required?:

$default the default value to use.:

Return value

$field field definition array

2 calls to ContentMigrateTestCase::setupField()
ContentMigrateListTestCase::setupField in modules/content_migrate/tests/content_migrate.test
Slightly different from setupField in text case.
ContentMigrateTextTestCase::setupField in modules/content_migrate/tests/content_migrate.test
Setup a field definition array based on parameters.
2 methods override ContentMigrateTestCase::setupField()
ContentMigrateListTestCase::setupField in modules/content_migrate/tests/content_migrate.test
Slightly different from setupField in text case.
ContentMigrateTextTestCase::setupField in modules/content_migrate/tests/content_migrate.test
Setup a field definition array based on parameters.

File

modules/content_migrate/tests/content_migrate.test, line 92
Content Migrate Test Cases

Class

ContentMigrateTestCase
@class Content Migrate Test Case. You should use this as the parent class for your content migrate tests.

Code

function setupField($type, $widget, $multiple = 0, $required = 0, $default = '') {

  // This is going to look a little different from exported CCK
  // fields. I want to be pretty efficient in the insert phase.
  // Apologies for any confusion this might cause.
  $field = array(
    'label' => $this
      ->randomName(8),
    'field_name' => 'field_' . strtolower($this
      ->randomName(4)),
    'type' => $type,
    'widget_type' => $widget,
    'change' => 'Change basic information',
    'op' => 'Save field settings',
    'description' => $this
      ->randomName(25),
    'module' => $type,
    'widget_module' => '',
    // fill in later
    'weight' => '0',
    'required' => $required,
    'multiple' => $multiple,
    'db_storage' => 1,
    'global_settings' => array(),
    'widget_settings' => array(
      'default_value' => array(),
      // fill in later
      'default_value_php' => '',
      // fill in later
      'default_value_widget' => NULL,
    ),
    'db_columns' => array(
      'value' => array(),
    ),
    'display_settings' => array(
      'label' => array(
        'format' => 'inline',
        'exclude' => 0,
      ),
      'teaser' => array(
        'format' => 'default',
        'exclude' => 0,
      ),
      'full' => array(
        'format' => 'default',
        'exclude' => 0,
      ),
    ),
  );
  for ($i = 0; $i <= $multiple; $i++) {
    $field['widget_settings']['default_value'][] = array(
      'value' => $default,
    );
  }
  return $field;
}