public function testSetRelationship() { $view = Views::
getView('test_handler_relationships'
);
$view->
setDisplay();
// Setup a broken relationship.
$view->
addHandler('default', 'relationship',
$this->
randomMachineName(),
$this->
randomMachineName(),
[], 'broken_relationship'
);
// Setup a valid relationship.
$view->
addHandler('default', 'relationship', 'comment_field_data', 'node',
['relationship' => 'cid'
], 'valid_relationship'
);
$view->
initHandlers();
$field =
$view->field
['title'
];
$field->options
['relationship'
] = NULL;
$field->
setRelationship();
$this->
assertNull($field->relationship, 'Make sure that an empty relationship does not create a relationship on the field.'
);
$field->options
['relationship'
] =
$this->
randomMachineName();
$field->
setRelationship();
$this->
assertNull($field->relationship, 'Make sure that a random relationship does not create a relationship on the field.'
);
$field->options
['relationship'
] = 'broken_relationship';
$field->
setRelationship();
$this->
assertNull($field->relationship, 'Make sure that a broken relationship does not create a relationship on the field.'
);
$field->options
['relationship'
] = 'valid_relationship';