You are here

function MediaFileFieldTestCase::createFileField in D7 Media 7.2

Same name and namespace in other branches
  1. 7.4 tests/media.test \MediaFileFieldTestCase::createFileField()
  2. 7.3 tests/media.test \MediaFileFieldTestCase::createFileField()

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.

5 calls to MediaFileFieldTestCase::createFileField()
MediaElementSettingsTestCase::testInsecureSettings in tests/media.test
Tests that the field widget does not contain the insecure settings.
MediaElementSettingsTestCase::testWidgetSettings in tests/media.test
Tests the media file field widget settings.
MediaFileFieldDisplayTestCase::testNodeDisplay in tests/media.test
Tests normal formatter display on node display.
MediaFileFieldRevisionTestCase::testRevisions in tests/media.test
Tests creating multiple revisions of a node and managing attached files.
MediaFileFieldValidateTestCase::testRequired in tests/media.test
Tests the required property on file fields.

File

tests/media.test, line 113
Tests for media.module.

Class

MediaFileFieldTestCase
Provides methods specifically for testing Media 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);
}