You are here

protected function WebformViewsTestBase::initView in Webform Views Integration 8.5

Initialize and save the view.

Parameters

\Drupal\webform\WebformInterface $webform: Webform to use as a filter condition in the view. View will contain submissions only from this webform.

array $handlers: Array of additional handlers to apply to the view.

string $view_id: ID of the view to initialize.

Return value

\Drupal\views\Entity\View Initialized and saved into DB view.

8 calls to WebformViewsTestBase::initView()
WebformViewsArgumentTestBase::testArgument in tests/src/Kernel/argument/WebformViewsArgumentTestBase.php
Test argument handler.
WebformViewsFieldTestBase::testClickSort in tests/src/Kernel/field/WebformViewsFieldTestBase.php
Test click sorting functionality.
WebformViewsFieldTestBase::testField in tests/src/Kernel/field/WebformViewsFieldTestBase.php
Test field rendering.
WebformViewsFieldTestBase::testMultiValueAllInOne in tests/src/Kernel/field/WebformViewsFieldTestBase.php
Test the multivalue element placing all values into single cell.
WebformViewsFieldTestBase::testMultiValueDeltaOffset in tests/src/Kernel/field/WebformViewsFieldTestBase.php
Test the multivalue element placing single value into a cell.

... See full list

File

tests/src/Kernel/WebformViewsTestBase.php, line 156

Class

WebformViewsTestBase
Reasonable starting point for testing integration between webform and views.

Namespace

Drupal\Tests\webform_views\Kernel

Code

protected function initView(WebformInterface $webform, array $handlers, $view_id = 'webform_views_test') {
  $view = View::load($view_id);

  /** @var \Drupal\views\ViewExecutable $executable */
  $executable = $view
    ->getExecutable();
  foreach ($handlers as $handler_type => $v) {
    foreach ($v as $handler) {
      $executable
        ->addHandler('default', $handler_type, $handler['table'], $handler['field'], $handler['options'], isset($handler['id']) ? $handler['id'] : NULL);
    }
  }
  $view
    ->save();

  // Let's reload the view because some handlers might initialize differently
  // since we've changed views configuration.
  $view = View::load($view
    ->id());
  return $view;
}