protected function EntityViewsDataTest::setupBaseFields in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/EntityViewsDataTest.php \Drupal\Tests\views\Unit\EntityViewsDataTest::setupBaseFields()
Helper method to setup base fields.
Parameters
\Drupal\Core\Field\BaseFieldDefinition[] $base_fields: The base fields which are adapted.
Return value
\Drupal\Core\Field\BaseFieldDefinition[] The setup base fields.
3 calls to EntityViewsDataTest::setupBaseFields()
- EntityViewsDataTest::testBaseTableFields in core/
modules/ views/ tests/ src/ Unit/ EntityViewsDataTest.php - Tests fields on the base table.
- EntityViewsDataTest::testDataTableFields in core/
modules/ views/ tests/ src/ Unit/ EntityViewsDataTest.php - Tests fields on the data table.
- EntityViewsDataTest::testRevisionTableFields in core/
modules/ views/ tests/ src/ Unit/ EntityViewsDataTest.php - Tests fields on the revision table.
File
- core/
modules/ views/ tests/ src/ Unit/ EntityViewsDataTest.php, line 137 - Contains \Drupal\Tests\views\Unit\EntityViewsDataTest.
Class
- EntityViewsDataTest
- @coversDefaultClass \Drupal\views\EntityViewsData @group Views
Namespace
Drupal\Tests\views\UnitCode
protected function setupBaseFields(array $base_fields) {
// Add a description field to the fields supplied by the EntityTest
// classes. This example comes from the taxonomy Term entity.
$base_fields['description'] = BaseFieldDefinition::create('text_long')
->setLabel(t('Description'))
->setDescription(t('A description of the term.'))
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
))
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', array(
'type' => 'text_textfield',
'weight' => 0,
))
->setDisplayConfigurable('form', TRUE);
// Add a URL field; this example is from the Comment entity.
$base_fields['homepage'] = BaseFieldDefinition::create('uri')
->setLabel(t('Homepage'))
->setDescription(t("The comment author's home page address."))
->setTranslatable(TRUE)
->setSetting('max_length', 255);
foreach ($base_fields as $name => $base_field) {
$base_field
->setName($name);
}
return $base_fields;
}