You are here

class ViewsHandlerManyToOneTest in Views (for Drupal 7) 7.3

Tests the many to one helper handler class.

Hierarchy

Expanded class hierarchy of ViewsHandlerManyToOneTest

File

tests/handlers/views_handler_manytoone.test, line 6

View source
class ViewsHandlerManyToOneTest extends ViewsSqlTest {

  /**
   * Field definitions used by this test.
   *
   * @var array
   */
  protected $fields;

  /**
   * Instances of fields used by this test.
   *
   * @var array
   */
  protected $instances;

  /**
   * Nodes used by this test.
   *
   * @var object[]
   */
  protected $nodes;

  /**
   * Accounts used by this test.
   *
   * @var object[]
   */
  protected $accounts;

  /**
   * Terms used by this test.
   *
   * @var object[]
   */
  protected $terms;

  /**
   * Provide the test's meta information.
   */
  public static function getInfo() {
    return array(
      'name' => 'Handler: Many To One Helper',
      'description' => 'Tests the many to one helper handler',
      'group' => 'Views Handlers',
    );
  }

  /**
   * Clears views data cache.
   */
  protected function clearViewsDataCache() {
    drupal_static_reset('_views_fetch_data_cache');
    drupal_static_reset('_views_fetch_data_recursion_protected');
    drupal_static_reset('_views_fetch_data_fully_loaded');
  }

  /**
   * Returns a new term with random properties.
   *
   * @param string $vocabulary
   *   Vocabulary ID to create term in.
   *
   * @return object
   *   Term with random properties.
   */
  protected function createTerm($vocabulary) {
    $term = new stdClass();
    $term->name = $this
      ->randomName();
    $term->description = $this
      ->randomName();

    // Use the first available text format.
    $term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)
      ->fetchField();
    $term->vid = $vocabulary->vid;
    taxonomy_term_save($term);
    return $term;
  }

  /**
   * {@inheritdoc}
   */
  public function setUp(array $modules = array()) {
    parent::setUp($modules);

    // Create boolean field.
    $this->fields[0] = array(
      'field_name' => 'field_bool',
      'type' => 'list_boolean',
      'cardinality' => 1,
      'settings' => array(
        'allowed_values' => array(
          0 => '',
          1 => '',
        ),
      ),
    );
    $this->fields[0] = field_create_field($this->fields[0]);

    // Create text list field.
    $this->fields[1] = array(
      'field_name' => 'field_list',
      'type' => 'list_text',
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
      'settings' => array(
        'allowed_values' => array(
          1 => '1',
          2 => '2',
          3 => '3',
        ),
      ),
    );
    $this->fields[1] = field_create_field($this->fields[1]);

    // Create boolean field instance for article nodes.
    $instance = array(
      'field_name' => $this->fields[0]['field_name'],
      'entity_type' => 'node',
      'bundle' => 'article',
      'widget' => array(
        'type' => 'options_onoff',
      ),
    );
    $this->instances[0][] = field_create_instance($instance);

    // Create text list field instance for article nodes.
    $instance = array(
      'field_name' => $this->fields[1]['field_name'],
      'entity_type' => 'node',
      'bundle' => 'article',
      'widget' => array(
        'type' => 'options_buttons',
      ),
    );
    $this->instances[1][] = field_create_instance($instance);

    // Create boolean field instance for users.
    $instance = array(
      'field_name' => $this->fields[0]['field_name'],
      'entity_type' => 'user',
      'bundle' => 'user',
      'widget' => array(
        'type' => 'options_onoff',
      ),
    );
    $this->instances[0][] = field_create_instance($instance);

    // Create text list field instance for users.
    $instance = array(
      'field_name' => $this->fields[1]['field_name'],
      'entity_type' => 'user',
      'bundle' => 'user',
      'widget' => array(
        'type' => 'options_buttons',
      ),
    );
    $this->instances[1][] = field_create_instance($instance);

    // Create tags field instance for users.
    $instance = array(
      'field_name' => 'field_tags',
      'entity_type' => 'user',
      'bundle' => 'user',
    );
    $this->instances[2][] = field_create_instance($instance);

    // Clear views data cache.
    $this
      ->clearViewsDataCache();

    // Create 62 tags.
    $vocabulary = taxonomy_vocabulary_machine_name_load('tags');
    for ($i = 0; $i < 62; $i++) {
      $this->terms[] = $this
        ->createTerm($vocabulary);
    }

    // Create a node where the field_bool is checked, field_list is '1' and
    // tag is term 2.
    $node = array();
    $node['type'] = 'article';
    $node[$this->fields[0]['field_name']][LANGUAGE_NONE][]['value'] = '1';
    $node[$this->fields[1]['field_name']][LANGUAGE_NONE][]['value'] = '1';
    $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[1]->tid;
    $this->nodes[0] = $this
      ->drupalCreateNode($node);

    // Create a node where the field_bool is not checked, field_list is empty
    // and tag is term 1.
    $node = array();
    $node['type'] = 'article';
    $node[$this->fields[0]['field_name']] = array();
    $node[$this->fields[1]['field_name']] = array();
    $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid;
    $this->nodes[1] = $this
      ->drupalCreateNode($node);

    // Create a node where the field_bool is not checked, field_list is empty
    // and tag is term 1 and 2.
    $node = array();
    $node['type'] = 'article';
    $node[$this->fields[0]['field_name']] = array();
    $node[$this->fields[1]['field_name']] = array();
    $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid;
    $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[1]->tid;
    $this->nodes[2] = $this
      ->drupalCreateNode($node);

    // Create a user where field_bool is checked, field_list is '1' and tag is
    // term 1.
    $permissions = array(
      'access content',
    );
    $account = $this
      ->drupalCreateUser($permissions);
    $account->{$this->fields[0]['field_name']}[LANGUAGE_NONE][]['value'] = '1';
    $account->{$this->fields[1]['field_name']}[LANGUAGE_NONE][]['value'] = '1';
    $account->field_tags[LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid;
    $this->accounts[0] = user_save($account);
  }

  /**
   * Tests "none of" filter with terms in excess of JOIN limit selected.
   */
  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.');
  }

  /**
   * Tests duplicate grouped "none of" filters on boolean field.
   */
  public function testGroupedNoneOf() {
    $view = $this
      ->getGroupedNoneOfTestView();
    $this
      ->executeView($view);

    // Assert that nodes have been created and have expected field values.
    $value = field_get_items('node', $this->nodes[0], $this->fields[0]['field_name'], LANGUAGE_NONE);
    $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
    $this
      ->assertIdentical($value, 1, 'First node has been created and boolean field is checked.');
    $value = field_get_items('node', $this->nodes[1], $this->fields[0]['field_name'], LANGUAGE_NONE);
    $this
      ->assertFalse($value, 'Second node has been created and boolean field is not checked.');
    $value = field_get_items('node', $this->nodes[2], $this->fields[0]['field_name'], LANGUAGE_NONE);
    $this
      ->assertFalse($value, 'Third node has been created and boolean field is not checked.');

    // Assert that user has been created and has expected field values.
    $value = field_get_items('user', $this->accounts[0], $this->fields[0]['field_name'], LANGUAGE_NONE);
    $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
    $this
      ->assertIdentical($value, 1, 'User has been created and boolean field is checked.');

    // 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, 2, 'View has two results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2, 'View result has correct node IDs.');
  }

  /**
   * Tests duplicate grouped "one of" filters on taxonomy term field.
   */
  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.');
    $value = field_get_items('node', $this->nodes[2], 'field_tags', LANGUAGE_NONE);
    $value = !empty($value[0]['tid']) && !empty($value[1]['tid']);
    $this
      ->assertTrue($value, 'Third node has been created and tags field references both terms 1 and 2.');

    // 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, 2, 'View has two results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2, 'View result has correct node IDs.');
  }

  /**
   * Tests exposed filter with "Reduce duplicates." and grouped options.
   */
  public function testReducedExposedGroupedOptions() {

    // Assert that nodes have been created and have expected field values.
    $value = field_get_items('node', $this->nodes[0], 'field_list', LANGUAGE_NONE);
    $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
    $this
      ->assertIdentical($value, 1, 'First node has been created and list field has value 1.');
    $value = field_get_items('node', $this->nodes[1], 'field_list', LANGUAGE_NONE);
    $this
      ->assertFalse($value, 'Second node has been created and list field is empty.');
    $value = field_get_items('node', $this->nodes[2], 'field_list', LANGUAGE_NONE);
    $this
      ->assertFalse($value, 'Third node has been created and list field is empty.');

    // Assert that user has been created and has expected field values.
    $value = field_get_items('user', $this->accounts[0], 'field_list', LANGUAGE_NONE);
    $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
    $this
      ->assertIdentical($value, 1, 'User has been created and list field has value 1.');

    // Assert that node ID with empty field value matches user ID so that the
    // node would be excluded from the result option 1, 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.');

    // Default option: Any.
    $view = $this
      ->getReducedExposedGroupedOptionsTestView();
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 3, 'Default option: View has three results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[0]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
    $result3 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2 && $result3, 'Default option: View result has correct node ID.');

    // Option 1: Is none of 1 or 2.
    $view = $this
      ->getReducedExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_list_value' => '1',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 2, 'Option 1: View has two results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2, 'Option 1: View result has correct node ID.');

    // Option 2: Is one of 1.
    $view = $this
      ->getReducedExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_list_value' => '2',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 1, 'Option 2: View has one result.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $this
      ->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 2: View result has correct node ID.');

    // Option 3: Is one of 1 or 2.
    $view = $this
      ->getReducedExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_list_value' => '3',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 1, 'Option 3: View has one result.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $this
      ->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 3: View result has correct node ID.');

    /* @todo: Fix and uncomment in issue #3045168.
     * // Option 4: Is all of 1 and 2.
     * $view = $this->getReducedExposedGroupedOptionsTestView();
     * $view->set_exposed_input(array(
     *   'field_list_value' => '4',
     * ));
     * $this->executeView($view);
     *
     * // Assert correct result set.
     * $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1;
     * $this->assertEqual($result_count, 0, 'Option 4: View has empty result.');
     */

    // Option 5: Is empty.
    $view = $this
      ->getReducedExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_list_value' => '5',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 2, 'Option 5: View has two results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2, 'Option 5: View result has correct node IDs.');

    // Option 6: Is not empty.
    $view = $this
      ->getReducedExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_list_value' => '6',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 1, 'Option 6: View has one result.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $this
      ->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 6: View result has correct node ID.');
  }

  /**
   * Tests exposed filter on term ID with grouped options.
   */
  public function testTermIdExposedGroupedOptions() {

    // 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 option 1, 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.');

    // Default option: Any.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 3, 'Default option: View has three results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[0]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
    $result3 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2 && $result3, 'Default option: View result has correct node ID.');

    // Option 1: Is none of 2.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_tags_tid' => '1',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 1, 'Option 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, 'Option 1: View result has correct node ID.');

    // Option 2: Is none of 1 or 2.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_tags_tid' => '2',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1;
    $this
      ->assertEqual($result_count, 0, 'Option 2: View has empty result.');

    // Option 3: Is one of 1.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_tags_tid' => '3',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $this
      ->assertEqual($result_count, 2, 'Option 3: View has two results.');
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2, 'Option 3: View result has correct node ID.');

    // Option 4: Is one of 1 or 2.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_tags_tid' => '4',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[0]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
    $result3 = $nid === (int) $this->nodes[2]->nid;
    $nid = isset($view->result[3]->nid) ? (int) $view->result[3]->nid : 0;
    $result4 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2 && $result3 && $result4, 'Option 4: View result has correct node ID.');
    $this
      ->verbose($view->result);
    $this
      ->assertEqual($result_count, 4, 'Option 4: View has four results.');

    /* @todo: Fix and uncomment in issue #3045168.
     * // Option 5: Is all of 1 and 2.
     * $view = $this->getTermIdExposedGroupedOptionsTestView();
     * $view->set_exposed_input(array(
     *   'field_tags_tid' => '5',
     * ));
     * $this->executeView($view);
     *
     * // Assert correct result set.
     * $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
     * $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
     * $this->assertIdentical($nid, (int) $this->nodes[2]->nid, 'Option 5: View result has correct node ID.');
     * $this->assertIdentical($result_count, 1, 'Option 5: View has one result.');
     */

    // Option 6: Is empty.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_tags_tid' => '6',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1;
    $this
      ->assertIdentical($result_count, 0, 'Option 6: View has empty result.');

    // Option 7: Is not empty.
    $view = $this
      ->getTermIdExposedGroupedOptionsTestView();
    $view
      ->set_exposed_input(array(
      'field_tags_tid' => '7',
    ));
    $this
      ->executeView($view);

    // Assert correct result set.
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
    $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
    $result1 = $nid === (int) $this->nodes[0]->nid;
    $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
    $result2 = $nid === (int) $this->nodes[1]->nid;
    $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
    $result3 = $nid === (int) $this->nodes[2]->nid;
    $nid = isset($view->result[3]->nid) ? (int) $view->result[3]->nid : 0;
    $result4 = $nid === (int) $this->nodes[2]->nid;
    $this
      ->assertTrue($result1 && $result2 && $result3 && $result4, 'Option 7: View result has correct node ID.');
    $this
      ->verbose($view->result);
    $this
      ->assertIdentical($result_count, 4, 'Option 7: View has four results.');
  }

  /**
   * Generates test_not view.
   */
  protected function getGroupedNoneOfTestView() {
    $view = new view();
    $view->name = 'test_not';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'test_not';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE;

    /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view
      ->new_display('default', 'Master', 'default');
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';

    /* Field: Content: Title */
    $handler->display->display_options['fields']['title']['id'] = 'title';
    $handler->display->display_options['fields']['title']['table'] = 'node';
    $handler->display->display_options['fields']['title']['field'] = 'title';
    $handler->display->display_options['fields']['title']['label'] = '';
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

    /* Sort criterion: Content: Nid */
    $handler->display->display_options['sorts']['nid']['id'] = 'nid';
    $handler->display->display_options['sorts']['nid']['table'] = 'node';
    $handler->display->display_options['sorts']['nid']['field'] = 'nid';
    $handler->display->display_options['filter_groups']['operator'] = 'OR';
    $handler->display->display_options['filter_groups']['groups'] = array(
      1 => 'AND',
      2 => 'AND',
    );

    /* Filter criterion: Content: Published */
    $handler->display->display_options['filters']['status']['id'] = 'status';
    $handler->display->display_options['filters']['status']['table'] = 'node';
    $handler->display->display_options['filters']['status']['field'] = 'status';
    $handler->display->display_options['filters']['status']['value'] = 1;
    $handler->display->display_options['filters']['status']['group'] = 1;
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

    /* Filter criterion: Content: Type */
    $handler->display->display_options['filters']['type']['id'] = 'type';
    $handler->display->display_options['filters']['type']['table'] = 'node';
    $handler->display->display_options['filters']['type']['field'] = 'type';
    $handler->display->display_options['filters']['type']['value'] = array(
      'article' => 'article',
    );
    $handler->display->display_options['filters']['type']['group'] = 1;

    /* Filter criterion: Field: field_bool (field_bool) */
    $handler->display->display_options['filters']['field_bool_value']['id'] = 'field_bool_value';
    $handler->display->display_options['filters']['field_bool_value']['table'] = 'field_data_field_bool';
    $handler->display->display_options['filters']['field_bool_value']['field'] = 'field_bool_value';
    $handler->display->display_options['filters']['field_bool_value']['operator'] = 'not';
    $handler->display->display_options['filters']['field_bool_value']['value'] = array(
      1 => '1',
    );
    $handler->display->display_options['filters']['field_bool_value']['group'] = 1;

    /* Filter criterion: Field: field_bool (field_bool) */
    $handler->display->display_options['filters']['field_bool_value_1']['id'] = 'field_bool_value_1';
    $handler->display->display_options['filters']['field_bool_value_1']['table'] = 'field_data_field_bool';
    $handler->display->display_options['filters']['field_bool_value_1']['field'] = 'field_bool_value';
    $handler->display->display_options['filters']['field_bool_value_1']['operator'] = 'not';
    $handler->display->display_options['filters']['field_bool_value_1']['value'] = array(
      1 => '1',
    );
    $handler->display->display_options['filters']['field_bool_value_1']['group'] = 2;

    /* Filter criterion: Content: Type */
    $handler->display->display_options['filters']['type_1']['id'] = 'type_1';
    $handler->display->display_options['filters']['type_1']['table'] = 'node';
    $handler->display->display_options['filters']['type_1']['field'] = 'type';
    $handler->display->display_options['filters']['type_1']['value'] = array(
      'article' => 'article',
    );
    $handler->display->display_options['filters']['type_1']['group'] = 2;

    /* Filter criterion: Content: Published */
    $handler->display->display_options['filters']['status_1']['id'] = 'status_1';
    $handler->display->display_options['filters']['status_1']['table'] = 'node';
    $handler->display->display_options['filters']['status_1']['field'] = 'status';
    $handler->display->display_options['filters']['status_1']['value'] = '1';
    $handler->display->display_options['filters']['status_1']['group'] = 2;
    return $view;
  }

  /**
   * Generates test_oneof view.
   */
  protected function getGroupedOneOfTestView() {
    $view = new view();
    $view->name = 'test_oneof';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'test_oneof';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE;

    /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view
      ->new_display('default', 'Master', 'default');
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';

    /* Field: Content: Title */
    $handler->display->display_options['fields']['title']['id'] = 'title';
    $handler->display->display_options['fields']['title']['table'] = 'node';
    $handler->display->display_options['fields']['title']['field'] = 'title';
    $handler->display->display_options['fields']['title']['label'] = '';
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

    /* Sort criterion: Content: Nid */
    $handler->display->display_options['sorts']['nid']['id'] = 'nid';
    $handler->display->display_options['sorts']['nid']['table'] = 'node';
    $handler->display->display_options['sorts']['nid']['field'] = 'nid';
    $handler->display->display_options['filter_groups']['operator'] = 'OR';
    $handler->display->display_options['filter_groups']['groups'] = array(
      1 => 'AND',
      2 => 'AND',
    );

    /* Filter criterion: Content: Tags (field_tags) */
    $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
    $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['value'] = array(
      1 => '1',
    );
    $handler->display->display_options['filters']['field_tags_tid']['group'] = 2;
    $handler->display->display_options['filters']['field_tags_tid']['reduce_duplicates'] = TRUE;
    $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
    $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';

    /* Filter criterion: Content: Tags (field_tags) */
    $handler->display->display_options['filters']['field_tags_tid_1']['id'] = 'field_tags_tid_1';
    $handler->display->display_options['filters']['field_tags_tid_1']['table'] = 'field_data_field_tags';
    $handler->display->display_options['filters']['field_tags_tid_1']['field'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid_1']['value'] = array(
      1 => '1',
    );
    $handler->display->display_options['filters']['field_tags_tid_1']['reduce_duplicates'] = TRUE;
    $handler->display->display_options['filters']['field_tags_tid_1']['type'] = 'select';
    $handler->display->display_options['filters']['field_tags_tid_1']['vocabulary'] = 'tags';
    return $view;
  }

  /**
   * Generates test_reduced_exposed_grouped_options view.
   */
  protected function getReducedExposedGroupedOptionsTestView() {
    $view = new view();
    $view->name = 'test_reduced_exposed_grouped_options';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'test_reduced_exposed_grouped_options';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE;

    /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view
      ->new_display('default', 'Master', 'default');
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';

    /* Field: Content: Title */
    $handler->display->display_options['fields']['title']['id'] = 'title';
    $handler->display->display_options['fields']['title']['table'] = 'node';
    $handler->display->display_options['fields']['title']['field'] = 'title';
    $handler->display->display_options['fields']['title']['label'] = '';
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

    /* Sort criterion: Content: Nid */
    $handler->display->display_options['sorts']['nid']['id'] = 'nid';
    $handler->display->display_options['sorts']['nid']['table'] = 'node';
    $handler->display->display_options['sorts']['nid']['field'] = 'nid';

    /* Filter criterion: Content: Published */
    $handler->display->display_options['filters']['status']['id'] = 'status';
    $handler->display->display_options['filters']['status']['table'] = 'node';
    $handler->display->display_options['filters']['status']['field'] = 'status';
    $handler->display->display_options['filters']['status']['value'] = 1;
    $handler->display->display_options['filters']['status']['group'] = 1;
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

    /* Filter criterion: Content: list (field_list) */
    $handler->display->display_options['filters']['field_list_value']['id'] = 'field_list_value';
    $handler->display->display_options['filters']['field_list_value']['table'] = 'field_data_field_list';
    $handler->display->display_options['filters']['field_list_value']['field'] = 'field_list_value';
    $handler->display->display_options['filters']['field_list_value']['exposed'] = TRUE;
    $handler->display->display_options['filters']['field_list_value']['expose']['operator_id'] = 'field_list_value_op';
    $handler->display->display_options['filters']['field_list_value']['expose']['label'] = 'list (field_list)';
    $handler->display->display_options['filters']['field_list_value']['expose']['operator'] = 'field_list_value_op';
    $handler->display->display_options['filters']['field_list_value']['expose']['identifier'] = 'field_list_value';
    $handler->display->display_options['filters']['field_list_value']['is_grouped'] = TRUE;
    $handler->display->display_options['filters']['field_list_value']['group_info']['label'] = 'list (field_list)';
    $handler->display->display_options['filters']['field_list_value']['group_info']['identifier'] = 'field_list_value';
    $handler->display->display_options['filters']['field_list_value']['group_info']['group_items'] = array(
      1 => array(
        'title' => 'Not 1 or 2',
        'operator' => 'not',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      2 => array(
        'title' => '1',
        'operator' => 'or',
        'value' => array(
          1 => '1',
        ),
      ),
      3 => array(
        'title' => '1 or 2',
        'operator' => 'or',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      4 => array(
        'title' => '1 and 2',
        'operator' => 'and',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      5 => array(
        'title' => 'empty',
        'operator' => 'empty',
        'value' => array(),
      ),
      6 => array(
        'title' => 'not empty',
        'operator' => 'not empty',
        'value' => array(),
      ),
    );
    return $view;
  }

  /**
   * Generates test_tid_exposed_grouped_options view.
   */
  protected function getTermIdExposedGroupedOptionsTestView() {
    $view = new view();
    $view->name = 'test_tid_exposed_grouped_options';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'test_tid_exposed_grouped_options';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE;

    /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view
      ->new_display('default', 'Master', 'default');
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';

    /* Field: Content: Title */
    $handler->display->display_options['fields']['title']['id'] = 'title';
    $handler->display->display_options['fields']['title']['table'] = 'node';
    $handler->display->display_options['fields']['title']['field'] = 'title';
    $handler->display->display_options['fields']['title']['label'] = '';
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

    /* Sort criterion: Content: Nid */
    $handler->display->display_options['sorts']['nid']['id'] = 'nid';
    $handler->display->display_options['sorts']['nid']['table'] = 'node';
    $handler->display->display_options['sorts']['nid']['field'] = 'nid';

    /* Filter criterion: Content: Published */
    $handler->display->display_options['filters']['status']['id'] = 'status';
    $handler->display->display_options['filters']['status']['table'] = 'node';
    $handler->display->display_options['filters']['status']['field'] = 'status';
    $handler->display->display_options['filters']['status']['value'] = 1;
    $handler->display->display_options['filters']['status']['group'] = 1;
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

    /* Filter criterion: Content: Tags (field_tags) */
    $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
    $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['value'] = array(
      1 => '1',
      2 => '2',
    );
    $handler->display->display_options['filters']['field_tags_tid']['exposed'] = TRUE;
    $handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op';
    $handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)';
    $handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op';
    $handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array(
      2 => '2',
    );
    $handler->display->display_options['filters']['field_tags_tid']['is_grouped'] = TRUE;
    $handler->display->display_options['filters']['field_tags_tid']['group_info']['label'] = 'Tags (field_tags)';
    $handler->display->display_options['filters']['field_tags_tid']['group_info']['identifier'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['group_info']['group_items'] = array(
      1 => array(
        'title' => 'Is none of 2',
        'operator' => 'not',
        'value' => array(
          2 => '2',
        ),
      ),
      2 => array(
        'title' => 'Is none of 1 or 2',
        'operator' => 'not',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      3 => array(
        'title' => 'Is one of 1',
        'operator' => 'or',
        'value' => array(
          1 => '1',
        ),
      ),
      4 => array(
        'title' => 'Is one of 1 or 2',
        'operator' => 'or',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      5 => array(
        'title' => 'Is all of 1 and 2',
        'operator' => 'and',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      6 => array(
        'title' => 'Is empty',
        'operator' => 'empty',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
      7 => array(
        'title' => 'Is not empty',
        'operator' => 'not empty',
        'value' => array(
          1 => '1',
          2 => '2',
        ),
      ),
    );
    $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
    $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
    return $view;
  }

  /**
   * Generates test_join_limit_none_of view.
   */
  protected function getJoinLimitNoneOfTestView() {
    $view = new view();
    $view->name = 'test_join_limit_none_of';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'test_join_limit_none_of';
    $view->core = 7;
    $view->api_version = '3.0';
    $view->disabled = FALSE;

    /* Edit this to true to make a default view disabled initially */

    /* Display: Master */
    $handler = $view
      ->new_display('default', 'Master', 'default');
    $handler->display->display_options['use_more_always'] = FALSE;
    $handler->display->display_options['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['style_plugin'] = 'default';
    $handler->display->display_options['row_plugin'] = 'fields';

    /* Field: Content: Title */
    $handler->display->display_options['fields']['title']['id'] = 'title';
    $handler->display->display_options['fields']['title']['table'] = 'node';
    $handler->display->display_options['fields']['title']['field'] = 'title';
    $handler->display->display_options['fields']['title']['label'] = '';
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;

    /* Sort criterion: Content: Post date */
    $handler->display->display_options['sorts']['created']['id'] = 'created';
    $handler->display->display_options['sorts']['created']['table'] = 'node';
    $handler->display->display_options['sorts']['created']['field'] = 'created';
    $handler->display->display_options['sorts']['created']['order'] = 'DESC';

    /* Filter criterion: Content: Published */
    $handler->display->display_options['filters']['status']['id'] = 'status';
    $handler->display->display_options['filters']['status']['table'] = 'node';
    $handler->display->display_options['filters']['status']['field'] = 'status';
    $handler->display->display_options['filters']['status']['value'] = 1;
    $handler->display->display_options['filters']['status']['group'] = 1;
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

    /* Filter criterion: Content: Tags (field_tags) */
    $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
    $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
    $handler->display->display_options['filters']['field_tags_tid']['operator'] = 'not';
    $handler->display->display_options['filters']['field_tags_tid']['value'] = array(
      2 => '2',
      3 => '3',
      4 => '4',
      5 => '5',
      6 => '6',
      7 => '7',
      8 => '8',
      9 => '9',
      10 => '10',
      11 => '11',
      12 => '12',
      13 => '13',
      14 => '14',
      15 => '15',
      16 => '16',
      17 => '17',
      18 => '18',
      19 => '19',
      20 => '20',
      21 => '21',
      22 => '22',
      23 => '23',
      24 => '24',
      25 => '25',
      26 => '26',
      27 => '27',
      28 => '28',
      29 => '29',
      30 => '30',
      31 => '31',
      32 => '32',
      33 => '33',
      34 => '34',
      35 => '35',
      36 => '36',
      37 => '37',
      38 => '38',
      39 => '39',
      40 => '40',
      41 => '41',
      42 => '42',
      43 => '43',
      44 => '44',
      45 => '45',
      46 => '46',
      47 => '47',
      48 => '48',
      49 => '49',
      50 => '50',
      51 => '51',
      52 => '52',
      53 => '53',
      54 => '54',
      55 => '55',
      56 => '56',
      57 => '57',
      58 => '58',
      59 => '59',
      60 => '60',
      61 => '61',
      62 => '62',
      63 => '63',
      64 => '64',
      65 => '65',
      66 => '66',
      67 => '67',
      68 => '68',
      69 => '69',
      61 => '61',
      62 => '62',
    );
    $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
    $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
    return $view;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$useSetupInstallationCache public property Whether to cache the installation part of the setUp() method.
DrupalTestCase::$useSetupModulesCache public property Whether to cache the modules installation part of the setUp() method.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::run public function Run all tests in this class.
DrupalWebTestCase::$additionalCurlOptions protected property Additional cURL options.
DrupalWebTestCase::$content protected property The content of the page currently loaded in the internal browser.
DrupalWebTestCase::$cookieFile protected property The current cookie file used by cURL.
DrupalWebTestCase::$cookies protected property The cookies of the page currently loaded in the internal browser.
DrupalWebTestCase::$curlHandle protected property The handle of the current cURL connection.
DrupalWebTestCase::$drupalSettings protected property The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser.
DrupalWebTestCase::$elements protected property The parsed version of the page.
DrupalWebTestCase::$generatedTestFiles protected property Whether the files were copied to the test files directory.
DrupalWebTestCase::$headers protected property The headers of the page currently loaded in the internal browser.
DrupalWebTestCase::$httpauth_credentials protected property HTTP authentication credentials (<username>:<password>).
DrupalWebTestCase::$httpauth_method protected property HTTP authentication method
DrupalWebTestCase::$loggedInUser protected property The current user logged in using the internal browser.
DrupalWebTestCase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing purposes.
DrupalWebTestCase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing purposes.
DrupalWebTestCase::$plainTextContent protected property The content of the page currently loaded in the internal browser (plain text version).
DrupalWebTestCase::$profile protected property The profile to install as a basis for testing. 20
DrupalWebTestCase::$redirect_count protected property The number of redirects followed during the handling of a request.
DrupalWebTestCase::$session_id protected property The current session ID, if available.
DrupalWebTestCase::$session_name protected property The current session name, if available.
DrupalWebTestCase::$url protected property The URL currently loaded in the internal browser.
DrupalWebTestCase::assertField protected function Asserts that a field exists with the given name or ID.
DrupalWebTestCase::assertFieldById protected function Asserts that a field exists in the current page with the given ID and value.
DrupalWebTestCase::assertFieldByName protected function Asserts that a field exists in the current page with the given name and value.
DrupalWebTestCase::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
DrupalWebTestCase::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
DrupalWebTestCase::assertLink protected function Pass if a link with the specified label is found, and optional with the specified index.
DrupalWebTestCase::assertLinkByHref protected function Pass if a link containing a given href (part) is found.
DrupalWebTestCase::assertMail protected function Asserts that the most recently sent e-mail message has the given value.
DrupalWebTestCase::assertMailPattern protected function Asserts that the most recently sent e-mail message has the pattern in it.
DrupalWebTestCase::assertMailString protected function Asserts that the most recently sent e-mail message has the string in it.
DrupalWebTestCase::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
DrupalWebTestCase::assertNoField protected function Asserts that a field does not exist with the given name or ID.
DrupalWebTestCase::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
DrupalWebTestCase::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
DrupalWebTestCase::assertNoFieldByXPath protected function Asserts that a field doesn't exist or its value doesn't match, by XPath.
DrupalWebTestCase::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
DrupalWebTestCase::assertNoLink protected function Pass if a link with the specified label is not found.
DrupalWebTestCase::assertNoLinkByHref protected function Pass if a link containing a given href (part) is not found.
DrupalWebTestCase::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
DrupalWebTestCase::assertNoPattern protected function Will trigger a pass if the perl regex pattern is not present in raw content.
DrupalWebTestCase::assertNoRaw protected function Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertNoResponse protected function Asserts the page did not return the specified response code.
DrupalWebTestCase::assertNoText protected function Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertNoTitle protected function Pass if the page title is not the given string.
DrupalWebTestCase::assertNoUniqueText protected function Pass if the text is found MORE THAN ONCE on the text version of the page.
DrupalWebTestCase::assertOptionSelected protected function Asserts that a select option in the current page is checked.
DrupalWebTestCase::assertPattern protected function Will trigger a pass if the Perl regex pattern is found in the raw content.
DrupalWebTestCase::assertRaw protected function Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertResponse protected function Asserts the page responds with the specified response code.
DrupalWebTestCase::assertText protected function Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertTextHelper protected function Helper for assertText and assertNoText.
DrupalWebTestCase::assertThemeOutput protected function Asserts themed output.
DrupalWebTestCase::assertTitle protected function Pass if the page title is the given string.
DrupalWebTestCase::assertUniqueText protected function Pass if the text is found ONLY ONCE on the text version of the page.
DrupalWebTestCase::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
DrupalWebTestCase::assertUrl protected function Pass if the internal browser's URL matches the given path.
DrupalWebTestCase::buildXPathQuery protected function Builds an XPath query.
DrupalWebTestCase::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
DrupalWebTestCase::checkForMetaRefresh protected function Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
DrupalWebTestCase::checkPermissions protected function Check to make sure that the array of permissions are valid.
DrupalWebTestCase::clickLink protected function Follows a link by name.
DrupalWebTestCase::constructFieldXpath protected function Helper function: construct an XPath for the given set of attributes and value.
DrupalWebTestCase::copySetupCache protected function Copy the setup cache from/to another table and files directory.
DrupalWebTestCase::cronRun protected function Runs cron in the Drupal installed by Simpletest.
DrupalWebTestCase::curlClose protected function Close the cURL handler and unset the handler.
DrupalWebTestCase::curlExec protected function Initializes and executes a cURL request.
DrupalWebTestCase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
DrupalWebTestCase::curlInitialize protected function Initializes the cURL connection.
DrupalWebTestCase::drupalCompareFiles protected function Compare two files based on size and file name.
DrupalWebTestCase::drupalCreateContentType protected function Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateNode protected function Creates a node based on default settings.
DrupalWebTestCase::drupalCreateRole protected function Creates a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalGetAJAX protected function Retrieve a Drupal path or an absolute path and JSON decode the result.
DrupalWebTestCase::drupalGetContent protected function Gets the current raw HTML of requested page.
DrupalWebTestCase::drupalGetHeader protected function Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed…
DrupalWebTestCase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the…
DrupalWebTestCase::drupalGetMails protected function Gets an array containing all e-mails sent during this test case.
DrupalWebTestCase::drupalGetNodeByTitle function Get a node from the database based on its title.
DrupalWebTestCase::drupalGetSettings protected function Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::drupalGetTestFiles protected function Get a list files that can be used in tests.
DrupalWebTestCase::drupalGetToken protected function Generate a token for the currently logged in user.
DrupalWebTestCase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
DrupalWebTestCase::drupalLogin protected function Log in a user with the internal browser.
DrupalWebTestCase::drupalLogout protected function
DrupalWebTestCase::drupalPost protected function Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
DrupalWebTestCase::drupalPostAJAX protected function Execute an Ajax submission.
DrupalWebTestCase::drupalSetContent protected function Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.
DrupalWebTestCase::drupalSetSettings protected function Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
DrupalWebTestCase::getAllOptions protected function Get all option elements, including nested options, in a select.
DrupalWebTestCase::getSelectedItem protected function Get the selected value from a select field.
DrupalWebTestCase::getSetupCacheKey protected function Returns the cache key used for the setup caching.
DrupalWebTestCase::getUrl protected function Get the current URL from the cURL handler.
DrupalWebTestCase::handleForm protected function Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
DrupalWebTestCase::loadSetupCache protected function Copies the cached tables and files for a cached installation setup.
DrupalWebTestCase::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
DrupalWebTestCase::preloadRegistry protected function Preload the registry from the testing site.
DrupalWebTestCase::prepareDatabasePrefix protected function Generates a database prefix for running tests.
DrupalWebTestCase::prepareEnvironment protected function Prepares the current environment for running the test.
DrupalWebTestCase::recursiveDirectoryCopy protected function Recursively copy one directory to another.
DrupalWebTestCase::refreshVariables protected function Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. 1
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::storeSetupCache protected function Store the installation setup to a cache.
DrupalWebTestCase::tearDown protected function Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix. 6
DrupalWebTestCase::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
DrupalWebTestCase::xpath protected function Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.
DrupalWebTestCase::__construct function Constructor for DrupalWebTestCase. Overrides DrupalTestCase::__construct 1
ViewsHandlerManyToOneTest::$accounts protected property Accounts used by this test.
ViewsHandlerManyToOneTest::$fields protected property Field definitions used by this test.
ViewsHandlerManyToOneTest::$instances protected property Instances of fields used by this test.
ViewsHandlerManyToOneTest::$nodes protected property Nodes used by this test.
ViewsHandlerManyToOneTest::$terms protected property Terms used by this test.
ViewsHandlerManyToOneTest::clearViewsDataCache protected function Clears views data cache.
ViewsHandlerManyToOneTest::createTerm protected function Returns a new term with random properties.
ViewsHandlerManyToOneTest::getGroupedNoneOfTestView protected function Generates test_not view.
ViewsHandlerManyToOneTest::getGroupedOneOfTestView protected function Generates test_oneof view.
ViewsHandlerManyToOneTest::getInfo public static function Provide the test's meta information.
ViewsHandlerManyToOneTest::getJoinLimitNoneOfTestView protected function Generates test_join_limit_none_of view.
ViewsHandlerManyToOneTest::getReducedExposedGroupedOptionsTestView protected function Generates test_reduced_exposed_grouped_options view.
ViewsHandlerManyToOneTest::getTermIdExposedGroupedOptionsTestView protected function Generates test_tid_exposed_grouped_options view.
ViewsHandlerManyToOneTest::setUp public function Sets up a Drupal site for running functional and integration tests. Overrides ViewsSqlTest::setUp
ViewsHandlerManyToOneTest::testGroupedNoneOf public function Tests duplicate grouped "none of" filters on boolean field.
ViewsHandlerManyToOneTest::testGroupedOneOf public function Tests duplicate grouped "one of" filters on taxonomy term field.
ViewsHandlerManyToOneTest::testJoinLimitNoneOf public function Tests "none of" filter with terms in excess of JOIN limit selected.
ViewsHandlerManyToOneTest::testReducedExposedGroupedOptions public function Tests exposed filter with "Reduce duplicates." and grouped options.
ViewsHandlerManyToOneTest::testTermIdExposedGroupedOptions public function Tests exposed filter on term ID with grouped options.
ViewsSqlTest::dataSet protected function A very simple test dataset. 8
ViewsSqlTest::drupalCreateTerm protected function Create a term.
ViewsSqlTest::enableViewsUi function This function allows to enable views ui from a higher class which can't change the setup function anymore.
ViewsSqlTest::getBasicPageView protected function Build and return a Page view of the views_test table.
ViewsSqlTest::getBasicView protected function Build and return a basic view of the views_test table. 4
ViewsSqlTest::schemaDefinition protected function The schema definition. 3
ViewsSqlTest::viewsData protected function The views data definition. 16
ViewsSqlTest::viewsPlugins protected function 3
ViewsTestCase::$sort_column protected property
ViewsTestCase::$sort_order protected property
ViewsTestCase::assertIdenticalResultset protected function Helper function: verify a result set returned by view.
ViewsTestCase::assertIdenticalResultsetHelper protected function
ViewsTestCase::assertNotIdenticalResultset protected function Helper function: verify a result set returned by view..
ViewsTestCase::executeView protected function Execute a view with debugging.
ViewsTestCase::helperButtonHasLabel protected function Check whether a button with a certain id exists and has a certain label.
ViewsTestCase::helperCompareFunction protected function Helper comparison function for orderResultSet().
ViewsTestCase::loginUser1 protected function Log in as user 1.
ViewsTestCase::orderResultSet protected function Order an array of array based on a column.
ViewsTestCase::verbose protected function Logs a verbose message in a text file. Overrides DrupalTestCase::verbose