You are here

public function ViewsHandlerManyToOneTest::testJoinLimitNoneOf in Views (for Drupal 7) 7.3

Tests "none of" filter with terms in excess of JOIN limit selected.

File

tests/handlers/views_handler_manytoone.test, line 220

Class

ViewsHandlerManyToOneTest
Tests the many to one helper handler class.

Code

public function testJoinLimitNoneOf() {
  $view = $this
    ->getJoinLimitNoneOfTestView();
  $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[0], '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[0]->uid, (int) $this->nodes[1]->nid, 'Node id of second node matches uid of first 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.');
}