You are here

protected function HandlerFieldFieldTest::prepareView in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::prepareView()
  2. 10 core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::prepareView()

Sets up the testing view with random field data.

Parameters

\Drupal\views\ViewExecutable $view: The view to add field data to.

4 calls to HandlerFieldFieldTest::prepareView()
HandlerFieldFieldTest::doTestFormatterSimpleFieldRender in core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php
Tests that fields with formatters runs as expected.
HandlerFieldFieldTest::doTestInaccessibleFieldRender in core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php
Tests inaccessible field rendering.
HandlerFieldFieldTest::doTestMultipleFieldRender in core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php
Tests multi-value field rendering.
HandlerFieldFieldTest::doTestSimpleFieldRender in core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php
Tests simple field rendering.

File

core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php, line 311

Class

HandlerFieldFieldTest
Tests the field rendering in views.

Namespace

Drupal\Tests\field\Kernel\Views

Code

protected function prepareView(ViewExecutable $view) {
  $view->storage
    ->invalidateCaches();
  $view
    ->initDisplay();
  foreach ($this->fieldStorages as $field_storage) {
    $field_name = $field_storage
      ->getName();
    $view->display_handler->options['fields'][$field_name]['id'] = $field_name;
    $view->display_handler->options['fields'][$field_name]['table'] = 'node__' . $field_name;
    $view->display_handler->options['fields'][$field_name]['field'] = $field_name;
  }
}