function FieldTest::testDefineOptionsWithDefaultFormatterOnFieldDefinition
Same name in other branches
- 9 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::testDefineOptionsWithDefaultFormatterOnFieldDefinition()
- 8.9.x core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::testDefineOptionsWithDefaultFormatterOnFieldDefinition()
- 10 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::testDefineOptionsWithDefaultFormatterOnFieldDefinition()
@covers ::defineOptions
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ field/ FieldTest.php, line 170
Class
- FieldTest
- @coversDefaultClass \Drupal\views\Plugin\views\field\EntityField @group views
Namespace
Drupal\Tests\views\Unit\Plugin\fieldCode
public function testDefineOptionsWithDefaultFormatterOnFieldDefinition() : void {
$definition = [
'entity_type' => 'test_entity',
'field_name' => 'title',
'default_formatter' => 'test_example',
'default_formatter_settings' => [
'link_to_entity' => TRUE,
],
];
$handler = new EntityField([], 'field', $definition, $this->entityTypeManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer, $this->entityRepository, $this->entityFieldManager, $this->entityTypeBundleInfo);
// Setup the entity field manager to allow fetching the storage definitions.
$title_storage = $this->getBaseFieldStorage();
$this->entityFieldManager
->expects($this->atLeastOnce())
->method('getFieldStorageDefinitions')
->with('test_entity')
->willReturn([
'title' => $title_storage,
]);
$options = [];
$handler->init($this->executable, $this->display, $options);
$this->assertEquals('test_example', $handler->options['type']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.