ContactFieldsTest.php in Zircon Profile 8
File
core/modules/contact/src/Tests/Views/ContactFieldsTest.php
View source
<?php
namespace Drupal\contact\Tests\Views;
use Drupal\views\Tests\ViewTestBase;
class ContactFieldsTest extends ViewTestBase {
public static $modules = array(
'field',
'text',
'contact',
);
protected $fieldStorage;
protected function setUp() {
parent::setUp();
$this->fieldStorage = entity_create('field_storage_config', array(
'field_name' => strtolower($this
->randomMachineName()),
'entity_type' => 'contact_message',
'type' => 'text',
));
$this->fieldStorage
->save();
entity_create('contact_form', array(
'id' => 'contact_message',
'label' => 'Test contact form',
))
->save();
entity_create('field_config', array(
'field_storage' => $this->fieldStorage,
'bundle' => 'contact_message',
))
->save();
$this->container
->get('views.views_data')
->clear();
}
public function testViewsData() {
$table_name = 'contact_message__' . $this->fieldStorage
->getName();
$data = $this->container
->get('views.views_data')
->get($table_name);
$this
->assertFalse($data, 'The field is not exposed to Views.');
}
}