function RelationEntityCollectorTest::testEntityCollector in Relation 8.2
Same name and namespace in other branches
- 8 relation_entity_collector/src/Tests/RelationEntityCollectorTest.php \Drupal\relation_entity_collector\Tests\RelationEntityCollectorTest::testEntityCollector()
Add relations to Node 1 and to Node 3 and then check that they are related.
File
- relation_entity_collector/
src/ Tests/ RelationEntityCollectorTest.php, line 43
Class
- RelationEntityCollectorTest
- Tests the Relation Entity Collector.
Namespace
Drupal\relation_entity_collector\TestsCode
function testEntityCollector() {
/* todo Uncomment when EntityCollectionBlock is fixed.
$node1key = 'node:' . $this->node1->id();
$node3key = 'node:' . $this->node3->id();
$relation_type = $this->relation_types['symmetric']['id'];
$edit = array(
"relation_type" => $relation_type,
"entity_key" => $node1key,
);
$this->drupalPostForm('node', $edit, t('Pick'));
$edit = array(
"relation_type" => $relation_type,
"entity_key" => $node3key,
);
$this->drupalPostForm('node', $edit, t('Pick'));
$this->drupalPostForm('node', array(), t('Save relation'));
// Now figure out the new relation id.
$result = array_keys(relation_query('node', $this->node3->nid)
->condition('relation_type', $relation_type)
->execute());
$path = 'relation/' . $result[0];
$link = l($relation_type, $path);
// Rebuild the message using the known bundle and entity labels to make sure
// the message contains those.
$bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo('node');
$node1_label = $bundles['article']['label'] . ': ' . $this->node1->label();
$node3_label = $bundles['page']['label'] . ': ' . $this->node3->label();
$items = array(
$node1_label,
$node3_label,
);
$item_list = array(
'#theme' => 'item_list',
'#items' => $items,
);
$list = \Drupal::service('renderer')->render($item_list);
$message = t('Created new !link from !list', array('!link' => $link, '!list' => $list));
$this->assertRaw($message, 'Created a new relation.');
$this->drupalGet($path);
$node1_uri = $this->node1->uri();
$node3_uri = $this->node3->uri();
$this->assertRaw(l($this->node1->label(), $node1_uri['path'], $node1_uri['options']), 'Node1 link found');
$this->assertRaw(l($this->node3->label(), $node3_uri['path'], $node3_uri['options']), 'Node1 link found');
*/
}