1.20.x views_handler_manytoone.test public ViewsHandlerManyToOneTest::testGroupedOneOf()

Tests duplicate grouped "one of" filters on taxonomy term field.

File

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.
  $value = field_get_items('user', $this->accounts[2], '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) $this->accounts[2]->uid, (int) $this->nodes[1]->nid, 'Node id of fourth node matches uid of third user.');

  // @todo get this test passing.
  // Assert correct result set.
  // $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  // debug('should be 1: ' . $result_count);
  // $this->assertEqual($result_count, 1, 'View has one result.');
  // $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  // debug('nid should be ' . $this->nodes[1]->nid . ': ' . $nid);
  // $this->assertIdentical($nid, (int) $this->nodes[1]->nid, 'View result has correct node id.');
}