public function RelationViewsTest::testDeduplication in Relation 8
Same name and namespace in other branches
- 8.2 src/Tests/RelationViewsTest.php \Drupal\relation\Tests\RelationViewsTest::testDeduplication()
Tests views deduplication.
File
- src/
Tests/ RelationViewsTest.php, line 493
Class
- RelationViewsTest
- Relation Views test
Namespace
Drupal\relation\TestsCode
public function testDeduplication() {
/*
for ($i = 0; $i < 2; $i++) {
$view = new view();
$view->base_table = 'node';
$handler = $view->new_display('default');
$handler->display->display_options['relationships']['relation_directional_entitydifferent_user']['id'] = 'relation_directional_entitydifferent_user';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_user']['table'] = 'node';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_user']['field'] = 'relation_directional_entitydifferent_user';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_user']['required'] = 1;
$handler->display->display_options['relationships']['relation_directional_entitydifferent_node']['id'] = 'relation_directional_entitydifferent_node';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_node']['table'] = 'users';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_node']['field'] = 'relation_directional_entitydifferent_node';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_node']['relationship'] = 'relation_directional_entitydifferent_user';
$handler->display->display_options['relationships']['relation_directional_entitydifferent_node']['required'] = 1;
$handler->display->display_options['relationships']['relation_directional_entitydifferent_node']['entity_deduplication_right'] = $i;
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid_1']['id'] = 'nid_1';
$handler->display->display_options['fields']['nid_1']['table'] = 'node';
$handler->display->display_options['fields']['nid_1']['field'] = 'nid';
$handler->display->display_options['fields']['nid_1']['relationship'] = 'relation_directional_entitydifferent_node';
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'users';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'relation_directional_entitydifferent_user';
$view->set_arguments(array($this->user1->uid));
$view->execute();
$this->assertEqual(count($view->result), 4 - 2 * $i);
$possible_nids = array($this->node3->nid => TRUE, $this->node4->nid => TRUE);
$fail = FALSE;
$all_results = array();
foreach ($view->result as $result) {
$this->assertTrue(isset($possible_nids[$result->nid]) && isset($possible_nids[$result->node_users_nid]), 'Correct nid found');
$this->assertFalse(isset($all_results[$result->nid][$result->node_users_nid]), 'No row duplication');
$all_results[$result->nid][$result->node_users_nid] = TRUE;
$fail = $fail || ($i && $result->nid == $result->node_users_nid);
}
if ($i) {
$this->assertFalse($fail, 'Deduplication worked');
}
}
*/
}