You are here

function FileFieldTestBase::createFileField in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::createFileField()

Creates a new file field.

Parameters

string $name: The name of the new field (all lowercase), exclude the "field_" prefix.

string $entity_type: The entity type.

string $bundle: The bundle that this field will be added to.

array $storage_settings: A list of field storage settings that will be added to the defaults.

array $field_settings: A list of instance settings that will be added to the instance defaults.

array $widget_settings: A list of widget settings that will be added to the widget defaults.

20 calls to FileFieldTestBase::createFileField()
FileFieldAttributesTest::setUp in core/modules/rdf/src/Tests/FileFieldAttributesTest.php
Sets up a Drupal site for running functional and integration tests.
FileFieldDisplayTest::testDefaultFileFieldDisplay in core/modules/file/src/Tests/FileFieldDisplayTest.php
Tests default display of File Field.
FileFieldDisplayTest::testNodeDisplay in core/modules/file/src/Tests/FileFieldDisplayTest.php
Tests normal formatter display on node display.
FileFieldFormatterAccessTest::testFileAccessHandler in core/modules/file/src/Tests/FileFieldFormatterAccessTest.php
Tests the custom access handler is invoked.
FileFieldPathTest::testUploadPath in core/modules/file/src/Tests/FileFieldPathTest.php
Tests the normal formatter display on node display.

... See full list

File

core/modules/file/src/Tests/FileFieldTestBase.php, line 79
Contains \Drupal\file\Tests\FileFieldTestBase.

Class

FileFieldTestBase
Provides methods specifically for testing File module's field handling.

Namespace

Drupal\file\Tests

Code

function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $field_settings = array(), $widget_settings = array()) {
  $field_storage = entity_create('field_storage_config', array(
    'entity_type' => $entity_type,
    'field_name' => $name,
    'type' => 'file',
    'settings' => $storage_settings,
    'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1,
  ));
  $field_storage
    ->save();
  $this
    ->attachFileField($name, $entity_type, $bundle, $field_settings, $widget_settings);
  return $field_storage;
}