You are here

protected function FieldsTest::addFieldToMockedView in Layout Plugin Views 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/FieldsTest.php \Drupal\Tests\layout_plugin_views\Unit\FieldsTest::addFieldToMockedView()

Parameters

$field_name:

$view:

bool $exclude: Set this to true if the field should have its exclude option set.

2 calls to FieldsTest::addFieldToMockedView()
FieldsTest::excludedFieldIsNotRendered in tests/src/Unit/FieldsTest.php
@test
FieldsTest::getMockedView in tests/src/Unit/FieldsTest.php
returns a static mocked view.

File

tests/src/Unit/FieldsTest.php, line 403

Class

FieldsTest
@coversDefaultClass \Drupal\layout_plugin_views\Plugin\views\row\Fields @group Panels

Namespace

Drupal\Tests\layout_plugin_views\Unit

Code

protected function addFieldToMockedView($field_name, $view, $exclude = FALSE) {
  $field = $this
    ->getMockBuilder(Field::class)
    ->disableOriginalConstructor()
    ->getMock();
  $field
    ->method('getItems')
    ->willReturn([
    [
      'rendered' => [
        '#markup' => $field_name,
      ],
    ],
  ]);
  if ($exclude) {
    $field->options['exclude'] = $exclude;
  }
  $view->field[$field_name] = $field;
}