function EntityViewsDataTest::testBaseTableFields
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsDataTest::testBaseTableFields()
- 8.9.x core/modules/views/tests/src/Unit/EntityViewsDataTest.php \Drupal\Tests\views\Unit\EntityViewsDataTest::testBaseTableFields()
- 10 core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsDataTest::testBaseTableFields()
Tests fields on the base table.
File
-
core/
modules/ views/ tests/ src/ Kernel/ Entity/ EntityViewsDataTest.php, line 383
Class
- EntityViewsDataTest
- Tests entity views data.
Namespace
Drupal\Tests\views\Kernel\EntityCode
public function testBaseTableFields() : void {
$data = $this->entityTypeManager
->getHandler('entity_test', 'views_data')
->getViewsData();
$this->assertNumericField($data['entity_test']['id']);
$this->assertViewsDataField($data['entity_test']['id'], 'id');
$this->assertUuidField($data['entity_test']['uuid']);
$this->assertViewsDataField($data['entity_test']['uuid'], 'uuid');
$this->assertStringField($data['entity_test']['type']);
$this->assertEquals('type', $data['entity_test']['type']['entity field']);
$this->assertLanguageField($data['entity_test']['langcode']);
$this->assertViewsDataField($data['entity_test']['langcode'], 'langcode');
$this->assertEquals('Original language', $data['entity_test']['langcode']['title']);
$this->assertStringField($data['entity_test']['name']);
$this->assertViewsDataField($data['entity_test']['name'], 'name');
$this->assertLongTextField($data['entity_test'], 'description');
$this->assertViewsDataField($data['entity_test']['description__value'], 'description');
$this->assertViewsDataField($data['entity_test']['description__format'], 'description');
$this->assertUriField($data['entity_test']['homepage']);
$this->assertViewsDataField($data['entity_test']['homepage'], 'homepage');
$this->assertEntityReferenceField($data['entity_test']['user_id']);
$this->assertViewsDataField($data['entity_test']['user_id'], 'user_id');
$relationship = $data['entity_test']['user_id']['relationship'];
$this->assertEquals('users_field_data', $relationship['base']);
$this->assertEquals('uid', $relationship['base field']);
// The string field name should be used as the 'entity field' but the actual
// field should reflect what the column mapping is using for multi-value
// base fields NOT just the field name. The actual column name returned from
// mappings in the test mocks is 'value'.
$this->assertStringField($data['entity_test__string']['string_value']);
$this->assertViewsDataField($data['entity_test__string']['string_value'], 'string');
$this->assertEquals([
'left_field' => 'id',
'field' => 'entity_id',
'extra' => [
[
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
],
],
], $data['entity_test__string']['table']['join']['entity_test']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.