function HandlerBaseTest::testGetEntityTypeForFieldWithRelationship
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldWithRelationship()
- 10 core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldWithRelationship()
- 9 core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldWithRelationship()
- 8.9.x core/modules/views/tests/src/Unit/Plugin/HandlerBaseTest.php \Drupal\Tests\views\Unit\Plugin\HandlerBaseTest::testGetEntityTypeForFieldWithRelationship()
Tests get entity type for field with relationship.
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ HandlerBaseTest.php, line 55
Class
Namespace
Drupal\Tests\views\Unit\PluginCode
public function testGetEntityTypeForFieldWithRelationship() : void {
$display = $this->createMock(DisplayPluginBase::class);
$viewsData = $this->createMock(ViewsData::class);
$handler = new TestHandler([], 'test_handler', []);
$options = [
'relationship' => 'test_relationship',
];
$handler->init($this->createStub(ViewExecutable::class), $display, $options);
$display->expects($this->atLeastOnce())
->method('getOption')
->with('relationships')
->willReturn([
'test_relationship' => [
'table' => 'test_entity_type_table',
'id' => 'test_relationship',
'field' => 'test_relationship',
],
]);
$viewsData->expects($this->atLeastOnce())
->method('get')
->willReturnMap([
[
'test_entity_type_table',
[
'table' => [
'entity type' => 'test_entity_type',
],
'test_relationship' => [
'relationship' => [
'base' => 'test_other_entity_type_table',
'base field' => 'id',
],
],
],
],
[
'test_other_entity_type_table',
[
'table' => [
'entity type' => 'test_other_entity_type',
],
],
],
]);
$handler->setViewsData($viewsData);
$this->assertEquals('test_other_entity_type', $handler->getEntityType());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.