You are here

protected function EFQViewsTermTestCase::testTermFilter in EntityFieldQuery Views Backend 7

File

tests/efq_views.test, line 576
Tests for EFQ Views query features.

Class

EFQViewsTermTestCase

Code

protected function testTermFilter() {
  foreach ($this->map as $test_key => $test) {
    if ($test) {
      $view = new view();
      $view->base_table = 'efq_efq_views_test';
      $handler = $view
        ->new_display('default');
      $handler->display->display_options['fields']['entity_id']['id'] = 'entity_id';
      $handler->display->display_options['fields']['entity_id']['table'] = 'efq_efq_views_test';
      $handler->display->display_options['fields']['entity_id']['field'] = 'entity_id';
      $handler->display->display_options['filters']['field_term']['id'] = 'field_term';
      $handler->display->display_options['filters']['field_term']['table'] = 'efq_efq_views_test';
      $handler->display->display_options['filters']['field_term']['field'] = 'field_term';
      foreach ($test as $term_key) {

        // Add a string cast just for kicks.
        $handler->display->display_options['filters']['field_term']['value'][] = (string) $this->terms[$term_key]->tid;
      }
      $handler->display->display_options['filters']['field_term']['vocabulary'] = 'test_vocab';
      $view
        ->execute();
      $ids = $this
        ->getIds($view->result);
      foreach ($this->expectedResults[$test_key] as $expectedResult) {
        $eid = $this->entities[$expectedResult]->eid;
        $this
          ->assertTrue(isset($ids[$eid]));
        unset($ids[$eid]);
      }
      $this
        ->assertFalse($ids);
    }
  }
}