class ContactFieldsTest
Same name and namespace in other branches
- 11.x core/modules/contact/tests/src/Kernel/Views/ContactFieldsTest.php \Drupal\Tests\contact\Kernel\Views\ContactFieldsTest
- 10 core/modules/contact/tests/src/Kernel/Views/ContactFieldsTest.php \Drupal\Tests\contact\Kernel\Views\ContactFieldsTest
- 8.9.x core/modules/contact/tests/src/Kernel/Views/ContactFieldsTest.php \Drupal\Tests\contact\Kernel\Views\ContactFieldsTest
Tests that no storage is created for the contact_message entity.
@group contact
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\contact\Kernel\Views\ContactFieldsTest extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ContactFieldsTest
File
-
core/
modules/ contact/ tests/ src/ Kernel/ Views/ ContactFieldsTest.php, line 15
Namespace
Drupal\Tests\contact\Kernel\ViewsView source
class ContactFieldsTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'contact',
'field',
'system',
'text',
'user',
'views',
];
/**
* Tests the views data generation.
*/
public function testViewsData() {
$this->installConfig([
'contact',
]);
FieldStorageConfig::create([
'type' => 'text',
'entity_type' => 'contact_message',
'field_name' => $field_name = strtolower($this->randomMachineName()),
])
->save();
ContactForm::create([
'id' => 'contact_message',
'label' => 'Test contact form',
])->save();
FieldConfig::create([
'entity_type' => 'contact_message',
'bundle' => 'contact_message',
'field_name' => $field_name,
])->save();
// Test that the field is not exposed to views, since contact_message
// entities have no storage.
$table_name = 'contact_message__' . $field_name;
$data = $this->container
->get('views.views_data')
->get($table_name);
$this->assertEmpty($data);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.