Drupal 8  8.0.2
FieldUnitTestBase Class Reference
Inheritance diagram for FieldUnitTestBase:

Static Public Attributes

static $modules = ['user', 'system', 'field', 'text', 'entity_test', 'field_test']
 

Protected Member Functions

 setUp ()
 
 createFieldWithStorage ($suffix= '', $entity_type= 'entity_test', $bundle=NULL)
 
 entitySaveReload (EntityInterface $entity)
 
 entityValidateAndSave (EntityInterface $entity)
 
 _generateTestFieldValues ($cardinality)
 
 assertFieldValues (EntityInterface $entity, $field_name, $expected_values, $langcode=LanguageInterface::LANGCODE_NOT_SPECIFIED, $column= 'value')
 

Protected Attributes

 $fieldTestData
 

Detailed Description

Parent class for Field API unit tests.

Member Function Documentation

_generateTestFieldValues (   $cardinality)
protected

Generate random values for a field_test field.

Parameters
$cardinalityNumber of values to generate.
Returns
An array of random values, in the format expected for field values.

Referenced by FieldAttachOtherTest\testEntityDisplayBuild(), FieldAttachStorageTest\testFieldAttachSaveLoad(), and TranslationTest\testTranslatableFieldSaveLoad().

Here is the caller graph for this function:

assertFieldValues ( EntityInterface  $entity,
  $field_name,
  $expected_values,
  $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED,
  $column = 'value' 
)
protected

Assert that a field has the expected values in an entity.

This function only checks a single column in the field values.

Parameters
EntityInterface$entityThe entity to test.
$field_nameThe name of the field to test
$expected_valuesThe array of expected values.
$langcode(Optional) The language code for the values. Defaults to ::LANGCODE_NOT_SPECIFIED.
$column(Optional) The name of the column to check. Defaults to 'value'.

References Drupal\entityManager(), format_string(), EntityInterface\getEntityTypeId(), and EntityInterface\id().

Here is the call graph for this function:

createFieldWithStorage (   $suffix = '',
  $entity_type = 'entity_test',
  $bundle = NULL 
)
protected

Create a field and an associated field storage.

Parameters
string$suffix(optional) A string that should only contain characters that are valid in PHP variable names as well.
string$entity_type(optional) The entity type on which the field should be created. Defaults to "entity_test".
string$bundle(optional) The entity type on which the field should be created. Defaults to the default bundle of the entity type.

References Unicode\strtolower().

Referenced by ConfigFieldDefinitionTest\setUp(), FieldAttachOtherTest\testEntityDisplayBuild(), and FieldAttachStorageTest\testFieldAttachSaveLoad().

Here is the call graph for this function:

Here is the caller graph for this function:

entitySaveReload ( EntityInterface  $entity)
protected

Saves and reloads an entity.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to save.
Returns
The entity, freshly reloaded from storage.

References EntityInterface\getEntityTypeId(), EntityInterface\id(), and EntityInterface\save().

Here is the call graph for this function:

entityValidateAndSave ( EntityInterface  $entity)
protected

Validate and save entity. Fail if violations are found.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to save.
Returns
void

References EntityInterface\save().

Referenced by BooleanItemTest\testBooleanItem(), EntityReferenceItemTest\testContentEntityReferenceItem(), TextWithSummaryItemTest\testCrudAndUpdate(), DateTimeItemTest\testDateTimeItem(), EmailItemTest\testEmailItem(), FileItemTest\testFileItem(), ImageItemTest\testImageItem(), LinkItemTest\testLinkItem(), NumberItemTest\testNumberItem(), TelephoneItemTest\testTestItem(), and UriItemTest\testUriField().

Here is the call graph for this function:

Here is the caller graph for this function:

setUp ( )
protected

Set the default field storage backend for fields created during tests.

References Drupal\entityManager().

Here is the call graph for this function:


The documentation for this class was generated from the following file: