You are here

public function ViewModeTest::getViewModeTestDataProvider in Search API Pages 8

Data provider for the getViewMode tests.

Return value

array The test data.

File

tests/src/Unit/ViewModeTest.php, line 21

Class

ViewModeTest
Class ViewModeTest.

Namespace

Drupal\Tests\search_api_page\Unit

Code

public function getViewModeTestDataProvider() {
  $testData = [];
  $testData['No configuration defaults to the global default'] = [
    'input' => [],
    'dataSourceId' => 'entity:node',
    'bundle' => 'article',
    'expected' => ViewMode::DEFAULT_VIEW_MODE,
  ];
  $testData['Unknown data source defaults to the global default'] = [
    'input' => [
      'entity:taxonomy_term' => [
        'default' => 'full',
        'overrides' => [],
      ],
    ],
    'dataSourceId' => 'entity:node',
    'bundle' => 'article',
    'expected' => ViewMode::DEFAULT_VIEW_MODE,
  ];
  $testData['Unconfigured default defaults to the global default'] = [
    'input' => [
      'entity:node' => [
        'overrides' => [],
      ],
    ],
    'dataSourceId' => 'entity:node',
    'bundle' => 'article',
    'expected' => ViewMode::DEFAULT_VIEW_MODE,
  ];
  $testData['Unknown bundle defaults to the configured default'] = [
    'input' => [
      'entity:node' => [
        'default' => 'full',
        'overrides' => [],
      ],
    ],
    'dataSourceId' => 'entity:node',
    'bundle' => 'article',
    'expected' => 'full',
  ];
  $testData['Empty bundle override defaults to the configured default'] = [
    'input' => [
      'entity:node' => [
        'default' => 'full',
        'overrides' => [
          'article' => '',
        ],
      ],
    ],
    'dataSourceId' => 'entity:node',
    'bundle' => 'article',
    'expected' => 'full',
  ];
  $testData['Override is used when configured'] = [
    'input' => [
      'entity:node' => [
        'default' => 'full',
        'overrides' => [
          'article' => 'teaser',
        ],
      ],
    ],
    'dataSourceId' => 'entity:node',
    'bundle' => 'article',
    'expected' => 'teaser',
  ];
  return $testData;
}