You are here

public function ExtraFieldDisplayPluginTest::displayPluginFormattedProvider in Extra Field 8.2

Data provider for formatted display plugins.

Return value

array Contains:

  • Plugin ID.
  • Plugin output as returned by ::view.
  • Return value of various plugin methods. Keyed by their method name.

File

tests/src/Kernel/ExtraFieldDisplayPluginTest.php, line 185

Class

ExtraFieldDisplayPluginTest
Kernel test for Extra Field display plugins.

Namespace

Drupal\Tests\extra_field\Kernel

Code

public function displayPluginFormattedProvider() {
  $info[] = [
    'single_text_test',
    [
      '#theme' => 'field',
      '#title' => 'Single text',
      '#label_display' => 'inline',
      '#view_mode' => '_custom',
      '#language' => 'und',
      '#field_name' => 'field_single_text',
      '#field_type' => 'single_text',
      '#field_translatable' => FALSE,
      '#entity_type' => 'node',
      '#bundle' => 'test',
      '#formatter' => 'single_text_test',
      '#is_multiple' => FALSE,
      '0' => [
        '#markup' => 'Output from SingleTextFieldTest',
      ],
    ],
    [
      'getLabel' => 'Single text',
      'getLabelDisplay' => 'inline',
      'getFieldName' => 'field_single_text',
      'getFieldType' => 'single_text',
      'isEmpty' => FALSE,
      'getLangcode' => 'und',
      'isTranslatable' => FALSE,
    ],
  ];
  $info[] = [
    'empty_formatted_test',
    [
      '#cache' => [
        'max-age' => 0,
      ],
    ],
    [
      'getLabel' => 'Empty field',
      'getLabelDisplay' => 'inline',
      'getFieldName' => 'extra_field_empty_formatted_test',
      'getFieldType' => 'extra_field',
      'isEmpty' => TRUE,
      'getLangcode' => 'und',
      'isTranslatable' => FALSE,
    ],
  ];
  $info[] = [
    'multiple_text_test',
    [
      '#theme' => 'field',
      '#title' => '',
      '#label_display' => 'hidden',
      '#view_mode' => '_custom',
      '#language' => 'und',
      '#field_name' => 'extra_field_multiple_text_test',
      '#field_type' => 'extra_field',
      '#field_translatable' => FALSE,
      '#entity_type' => 'node',
      '#bundle' => 'test',
      '#formatter' => 'multiple_text_test',
      '#is_multiple' => TRUE,
      '#cache' => [],
      '#children' => '',
      '0' => [
        '#markup' => 'Aap',
      ],
      '1' => [
        '#markup' => 'Noot',
      ],
      '2' => [
        '#markup' => 'Mies',
      ],
      '3' => [
        '#markup' => 'Wim',
      ],
      '4' => [
        '#markup' => 'Zus',
      ],
      '5' => [
        '#markup' => 'Jet',
      ],
    ],
    [
      'getLabel' => '',
      'getLabelDisplay' => 'hidden',
      'getFieldName' => 'extra_field_multiple_text_test',
      'getFieldType' => 'extra_field',
      'isEmpty' => FALSE,
      'getLangcode' => 'und',
      'isTranslatable' => FALSE,
    ],
  ];
  return $info;
}