function FileFieldTestCase::createFileField
7.x file.test | FileFieldTestCase::createFileField($name, $type_name, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) |
Creates a new file field.
Parameters
$name: The name of the new field (all lowercase), exclude the "field_" prefix.
$type_name: The node type that this field will be added to.
$field_settings: A list of field settings that will be added to the defaults.
$instance_settings: A list of instance settings that will be added to the instance defaults.
$widget_settings: A list of widget settings that will be added to the widget defaults.
11 calls to FileFieldTestCase::createFileField()
- FileFieldDisplayTestCase::testNodeDisplay in drupal-7.x/
modules/ file/ tests/ file.test - Tests normal formatter display on node display.
- FileFieldPathTestCase::testUploadPath in drupal-7.x/
modules/ file/ tests/ file.test - Tests the normal formatter display on node display.
- FileFieldRevisionTestCase::testRevisions in drupal-7.x/
modules/ file/ tests/ file.test - Tests creating multiple revisions of a node and managing attached files.
- FileFieldValidateTestCase::testFileExtension in drupal-7.x/
modules/ file/ tests/ file.test - Tests file extension checking.
- FileFieldValidateTestCase::testFileMaxSize in drupal-7.x/
modules/ file/ tests/ file.test - Tests the max file size validator.
File
- drupal-7.x/
modules/ file/ tests/ file.test, line 63 - Tests for file.module.
Class
- FileFieldTestCase
- Provides methods specifically for testing File module's field handling.
Code
function createFileField($name, $type_name, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) {
$field = array(
'field_name' => $name,
'type' => 'file',
'settings' => array(),
'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1,
);
$field['settings'] = array_merge($field['settings'], $field_settings);
field_create_field($field);
$this->attachFileField($name, 'node', $type_name, $instance_settings, $widget_settings);
}