You are here

protected function IntegrationTest::checkDataTypesTable in Search API 8

Tests if the data types table is available and contains correct values.

1 call to IntegrationTest::checkDataTypesTable()
IntegrationTest::testFramework in tests/src/Functional/IntegrationTest.php
Tests various operations via the Search API's admin UI.

File

tests/src/Functional/IntegrationTest.php, line 922

Class

IntegrationTest
Tests the overall functionality of the Search API framework and admin UI.

Namespace

Drupal\Tests\search_api\Functional

Code

protected function checkDataTypesTable() {
  $this
    ->drupalGet($this
    ->getIndexPath('fields'));
  $rows = $this
    ->xpath('//*[@id="search-api-data-types-table"]//table/tbody/tr');
  $this
    ->assertIsArray($rows);
  $this
    ->assertNotEmpty($rows);

  /** @var \Behat\Mink\Element\NodeElement $row */
  foreach ($rows as $row) {
    $columns = $row
      ->findAll('xpath', '/td');
    $label = $columns[0]
      ->getText();
    $icon = basename($columns[2]
      ->find('xpath', '/img')
      ->getAttribute('src'));
    $fallback = $columns[3]
      ->getText();

    // Make sure we display the right icon and fallback column.
    if (strpos($label, 'Unsupported') === 0) {
      $this
        ->assertEquals('error.svg', $icon, 'An error icon is shown for unsupported data types.');
      $this
        ->assertNotEquals($fallback, '', 'The fallback data type label is not empty for unsupported data types.');
    }
    else {
      $this
        ->assertEquals('check.svg', $icon, 'A check icon is shown for supported data types.');
      $this
        ->assertEquals('', $fallback, 'The fallback data type label is empty for supported data types.');
    }
  }
}