public function ContactFieldsTest::testViewsData

Tests the views data generation.

File

drupal/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php, line 62
Contains \Drupal\contact\Tests\Views\ContactFieldsTest.

Class

ContactFieldsTest
Tests which checks that no fieldapi fields are added on contact.

Namespace

Drupal\contact\Tests\Views

Code

public function testViewsData() {
  $field_name = $this->field['field_name'];
  $table_name = _field_sql_storage_tablename($this->field);
  $data = $this->container
    ->get('views.views_data')
    ->get($table_name);

  // Test that the expected data array is returned.
  $expected = array(
    '',
    '_value',
    '_format',
  );
  $this
    ->assertEqual(count($data), count($expected), 'The expected amount of array keys were found.');
  foreach ($expected as $suffix) {
    $this
      ->assertTrue(isset($data[$field_name . $suffix]));
  }
  $this
    ->assertTrue(empty($data['table']['join']), 'The field is not joined to the non existent contact message base table.');
}