3 namespace Drupal\Tests\ctools\Kernel;
5 use Drupal\Core\Plugin\Context\Context;
6 use Drupal\Core\Plugin\Context\ContextDefinition;
9 * @coversDefaultClass \Drupal\ctools\Plugin\RelationshipManagerInterface
12 class RelationshipManagerTest extends RelationshipsTestBase {
15 * @covers ::getDefinitions
17 public function testRelationshipConstraints() {
18 $definitions = $this->relationshipManager->getDefinitions();
25 $this->assertSame($expected, $definitions['typed_data_relationship:entity:node:body']['context']['base']->getConstraints());
27 // Check that typed data primitive labels are formatted properly.
28 $this->assertSame('Body from Page and Foo', (string) $definitions['typed_data_relationship:entity:node:body']['label']);
30 // Check that entity relationship labels are formatted properly.
31 $this->assertSame('Authored by Entity from Content', (string) $definitions['typed_data_entity_relationship:entity:node:uid']['label']);
33 // Check that language relationship labels are formatted properly.
34 $this->assertSame('Language Language from Content', (string) $definitions['typed_data_language_relationship:entity:node:langcode']['label']);
38 * @covers ::getDefinitionsForContexts
40 public function testRelationshipPluginAvailability() {
41 $context_definition = new ContextDefinition('entity:node');
43 'node' => new Context($context_definition, $this->entities['node1']),
45 $definitions = $this->relationshipManager->getDefinitionsForContexts($contexts);
46 //$this->assertTrue(isset($definitions['typed_data_relationship:entity:node:body']));
48 $context_definition = new ContextDefinition('entity:node');
50 'node' => new Context($context_definition, $this->entities['node2']),
52 $definitions = $this->relationshipManager->getDefinitionsForContexts($contexts);
53 $this->assertFalse(isset($definitions['typed_data_relationship:entity:node:body']));
55 $context_definition = new ContextDefinition('entity:node');
57 'node' => new Context($context_definition, $this->entities['node3']),
59 $definitions = $this->relationshipManager->getDefinitionsForContexts($contexts);
60 //$this->assertTrue(isset($definitions['typed_data_relationship:entity:node:body']));