3 namespace Drupal\contact\Tests\Views;
5 use Drupal\field\Entity\FieldConfig;
6 use Drupal\views\Tests\ViewTestBase;
7 use Drupal\field\Entity\FieldStorageConfig;
8 use Drupal\contact\Entity\ContactForm;
11 * Tests which checks that no fieldapi fields are added on contact.
15 class ContactFieldsTest extends ViewTestBase {
22 public static $modules = ['field', 'text', 'contact'];
25 * Contains the field storage definition for contact used for this test.
27 * @var \Drupal\field\Entity\FieldStorageConfig
29 protected $fieldStorage;
31 protected function setUp() {
34 $this->fieldStorage = FieldStorageConfig::create([
35 'field_name' => strtolower($this->randomMachineName()),
36 'entity_type' => 'contact_message',
39 $this->fieldStorage->save();
42 'id' => 'contact_message',
43 'label' => 'Test contact form',
47 'field_storage' => $this->fieldStorage,
48 'bundle' => 'contact_message',
51 $this->container->get('views.views_data')->clear();
55 * Tests the views data generation.
57 public function testViewsData() {
58 // Test that the field is not exposed to views, since contact_message
59 // entities have no storage.
60 $table_name = 'contact_message__' . $this->fieldStorage->getName();
61 $data = $this->container->get('views.views_data')->get($table_name);
62 $this->assertFalse($data, 'The field is not exposed to Views.');