You are here

views_exposed_groups_op.test in Views exposed groups 7.2

Views Exposed Groups Exposed Operator Test.

File

tests/views_exposed_groups_op.test
View source
<?php

/**
 * @file
 * Views Exposed Groups Exposed Operator Test.
 */

/**
 * Tests a view with exposed groups that also has exposed operators.
 */
class ViewsExposedGroupsExposedOperatorTest extends ViewsExposedGroupsTestBase {

  /**
   * Describes the test case.
   */
  public static function getInfo() {
    return [
      'name' => 'Views Exposed Groups Exposed Operator Test',
      'description' => 'Tests a view with exposed groups that also has exposed operators.',
      'group' => 'Views Exposed Groups',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function setUp(array $modules = []) {
    parent::setUp($modules);
    $this->defaultView
      ->set_display('default');
    $this->defaultView->display['default']->display_options['filters']['title']['expose']['use_operator'] = TRUE;
    $this->defaultView->display['default']->display_options['exposed_form'] = [
      'type' => 'views_exposed_groups',
      'options' => [
        'views_exposed_groups' => [
          'groups' => "Default\nAdvanced",
          'format_groups' => 'fieldsets',
          'vertical_tabs_summary' => '0',
          'group-title' => [
            'group' => '0',
            'filter_name' => 'title',
            'weight' => '-4',
          ],
          'group-nid' => [
            'group' => '1',
            'filter_name' => 'nid',
            'weight' => '-3',
          ],
          'group-uid' => [
            'group' => 'no-group',
            'filter_name' => 'uid',
            'weight' => '0',
          ],
        ],
      ],
    ];
    views_save_view($this->defaultView);
  }

  /**
   * Asserts that a filter with an exposed operator behaves correctly.
   */
  public function testExposedOperator() {
    $view_path = $this->defaultView
      ->get_path();
    $this
      ->drupalLogin($this->unprivilegedUser);
    $this
      ->drupalGet($view_path);

    // Asserts that the exposed filter with an exposed operator exists.
    $this
      ->assertFieldByName('title_op');
    $this
      ->assertFieldByName('title');
    $fieldset_legend = $this
      ->xpath('//fieldset/legend/span[text()="Title"]');
    $this
      ->assertEqual(1, count($fieldset_legend), 'Found the exposed filter label as the fieldset legend.');
  }

}

Classes

Namesort descending Description
ViewsExposedGroupsExposedOperatorTest Tests a view with exposed groups that also has exposed operators.