You are here

public function FieldTest::testDefineOptionsWithDefaultFormatterOnFieldDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 145
Contains \Drupal\Tests\views\Unit\Plugin\field\FieldTest.

Class

FieldTest
@coversDefaultClass \Drupal\views\Plugin\views\field\Field @group views

Namespace

Drupal\Tests\views\Unit\Plugin\field

Code

public function testDefineOptionsWithDefaultFormatterOnFieldDefinition() {
  $definition = [
    'entity_type' => 'test_entity',
    'field_name' => 'title',
    'default_formatter' => 'test_example',
    'default_formatter_settings' => [
      'link_to_entity' => TRUE,
    ],
  ];
  $handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);

  // Setup the entity manager to allow fetching the storage definitions.
  $title_storage = $this
    ->getBaseFieldStorage();
  $this->entityManager
    ->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']);
}