function EntityViewsDataTest::testDataTable
Same name in other branches
- 9 core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsDataTest::testDataTable()
- 10 core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsDataTest::testDataTable()
- 11.x core/modules/views/tests/src/Kernel/Entity/EntityViewsDataTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsDataTest::testDataTable()
Tests data_table support.
File
-
core/
modules/ views/ tests/ src/ Unit/ EntityViewsDataTest.php, line 227
Class
- EntityViewsDataTest
- @coversDefaultClass \Drupal\views\EntityViewsData @group Views
Namespace
Drupal\Tests\views\UnitCode
public function testDataTable() {
$entity_type = $this->baseEntityType
->set('data_table', 'entity_test_mul_property_data')
->set('id', 'entity_test_mul')
->set('translatable', TRUE)
->setKey('label', 'label');
$this->viewsData
->setEntityType($entity_type);
// Tests the join definition between the base and the data table.
$data = $this->viewsData
->getViewsData();
$base_views_data = $data['entity_test'];
// Ensure that the base table is set to the data table.
$this->assertEquals('id', $data['entity_test_mul_property_data']['table']['base']['field']);
$this->assertEquals('Entity test', $data['entity_test_mul_property_data']['table']['base']['title']);
$this->assertFalse(isset($data['entity_test']['table']['base']));
$this->assertEquals('entity_test_mul', $data['entity_test_mul_property_data']['table']['entity type']);
$this->assertEquals(FALSE, $data['entity_test_mul_property_data']['table']['entity revision']);
$this->assertEquals('Entity test', $data['entity_test_mul_property_data']['table']['group']);
$this->assertEquals('entity_test', $data['entity_test']['table']['provider']);
$this->assertEquals([
'field' => 'label',
'table' => 'entity_test_mul_property_data',
], $data['entity_test_mul_property_data']['table']['base']['defaults']);
// Ensure the join information is set up properly.
$this->assertCount(1, $base_views_data['table']['join']);
$this->assertEquals([
'entity_test_mul_property_data' => [
'left_field' => 'id',
'field' => 'id',
'type' => 'INNER',
],
], $base_views_data['table']['join']);
$this->assertFalse(isset($data['revision_table']));
$this->assertFalse(isset($data['revision_data_table']));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.