You are here

protected function BackendTest::checkMultiValuedInfo in Search API 8

Verifies that the stored information about multi-valued fields is correct.

1 call to BackendTest::checkMultiValuedInfo()
BackendTest::checkBackendSpecificFeatures in modules/search_api_db/tests/src/Kernel/BackendTest.php
Checks backend specific features.

File

modules/search_api_db/tests/src/Kernel/BackendTest.php, line 217

Class

BackendTest
Tests index and search capabilities using the Database search backend.

Namespace

Drupal\Tests\search_api_db\Kernel

Code

protected function checkMultiValuedInfo() {
  $db_info = $this
    ->getIndexDbInfo();
  $field_info = $db_info['field_tables'];
  $fields = [
    'name',
    'body',
    'type',
    'keywords',
    'category',
    'width',
    'search_api_datasource',
    'search_api_language',
  ];
  $multi_valued = [
    'name',
    'body',
    'keywords',
  ];
  foreach ($fields as $field_id) {
    $this
      ->assertArrayHasKey($field_id, $field_info, "Field info saved for field {$field_id}.");
    if (in_array($field_id, $multi_valued)) {
      $this
        ->assertFalse(empty($field_info[$field_id]['multi-valued']), "Field {$field_id} is stored as multi-value.");
    }
    else {
      $this
        ->assertTrue(empty($field_info[$field_id]['multi-valued']), "Field {$field_id} is not stored as multi-value.");
    }
  }
}