1 views_handler_manytoone.test | public ViewsHandlerManyToOneTest::testGroupedOneOf() |
Tests duplicate grouped "one of" filters on taxonomy term field.
File
- core/
modules/ views/ tests/ handlers/ views_handler_manytoone.test, line 212 - Definition of ViewsHandlerManyToOneTest.
Class
- ViewsHandlerManyToOneTest
- Tests the many to one helper handler class.
Code
public function testGroupedOneOf() {
$view = $this->getGroupedOneOfTestView();
$this->executeView($view);
// Assert that nodes have been created and have expected field values.
$value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE);
$value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
$this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.');
$value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE);
$value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
$this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.');
// Assert that user has been created and has expected field values.
$last_account = end($this->accounts);
$value = field_get_items('user', $last_account, 'field_tags', LANGUAGE_NONE);
$value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
$this->assertIdentical($value, 1, 'User has been created and tags field references term 1.');
// Assert that node ID with empty field value matches user ID so that the
// node would be excluded from the result, if the joins are missing extras.
$this->assertIdentical((int) $last_account->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of the latest user.');
// Assert correct result set.
$result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
$this->assertEqual($result_count, 1, 'View has one result.');
$nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
$this->assertIdentical($nid, (int) $this->nodes[1]->nid, 'View result has correct node ID.');
}