You are here

public function EntityAutocompleteWebformViewsTest::setUp in Webform Views Integration 8.5

Overrides WebformViewsTestBase::setUp

File

tests/src/Kernel/relationship/EntityAutocompleteWebformViewsTest.php, line 21

Class

EntityAutocompleteWebformViewsTest
Test relationship of 'entity_autocomplete' webform element.

Namespace

Drupal\Tests\webform_views\Kernel\relationship

Code

public function setUp() {
  parent::setUp();
  $this->webform_elements = [
    'element' => [
      '#type' => 'entity_autocomplete',
      '#title' => 'Entity Autocomplete',
      '#target_type' => $this->target_entity_type,
    ],
  ];

  /** @var \Drupal\Core\Entity\EntityTypeInterface $target_entity_type */
  $target_entity_type = $this->container
    ->get('entity_type.manager')
    ->getDefinition($this->target_entity_type);
  $this->view_handlers = [
    'relationship' => [
      [
        'id' => 'element',
        'table' => 'webform_submission_field_webform_element',
        'field' => 'webform_submission_value',
        'options' => [],
      ],
    ],
    'field' => [
      [
        'id' => 'entity_id',
        'table' => $target_entity_type
          ->getDataTable(),
        'field' => $target_entity_type
          ->getKey('id'),
        'options' => [
          'relationship' => 'element',
          'alter' => [],
          'empty' => '',
          'hide_empty' => FALSE,
          'empty_zero' => FALSE,
          'hide_alter_empty' => TRUE,
        ],
      ],
    ],
  ];
}