public function TypedDataEntityRelationshipPluginTest::testRelationship in Chaos Tool Suite (ctools) 8.3
@covers ::getRelationship
File
- tests/
src/ Kernel/ TypedDataEntityRelationshipPluginTest.php, line 30
Class
- TypedDataEntityRelationshipPluginTest
- @coversDefaultClass \Drupal\ctools\Plugin\Relationship\TypedDataEntityRelationship @group CTools
Namespace
Drupal\Tests\ctools\KernelCode
public function testRelationship() {
/** @var \Drupal\ctools\Plugin\RelationshipInterface $type_plugin */
$type_plugin = $this->relationshipManager
->createInstance('typed_data_entity_relationship:entity:node:type');
$type_plugin
->setContextValue('base', $this->entities['node1']);
$relationship = $type_plugin
->getRelationship();
$this
->assertTrue($relationship
->getContextValue() instanceof NodeType);
$this
->assertSame('entity:node_type', $relationship
->getContextDefinition()
->getDataType());
/** @var \Drupal\ctools\Plugin\RelationshipInterface $uid_plugin */
$uid_plugin = $this->relationshipManager
->createInstance('typed_data_entity_relationship:entity:node:uid');
$uid_plugin
->setContextValue('base', $this->entities['node3']);
$relationship = $uid_plugin
->getRelationship();
$this
->assertTrue($relationship
->getContextValue() instanceof User);
$this
->assertSame('entity:user', $relationship
->getContextDefinition()
->getDataType());
}