summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
blob: 03495c30bc8f4489cc6dd274d57acddea5d1c29f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php

class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
  public static function getInfo() {
    return array(
      'name' => 'Jump menu',
      'description' => 'Test jump menu style functionality.',
      'group' => 'Views Plugins',
    );
  }


  public function setUp() {
    parent::setUp();
    $this->nodes = array();
    $this->nodes['page'][] = $this->drupalCreateNode(array('type' => 'page'));
    $this->nodes['page'][] = $this->drupalCreateNode(array('type' => 'page'));
    $this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story'));
    $this->nodes['story'][] = $this->drupalCreateNode(array('type' => 'story'));

    $this->nodeTitles = array($this->nodes['page'][0]->title, $this->nodes['page'][1]->title, $this->nodes['story'][0]->title, $this->nodes['story'][1]->title);
  }


  /**
   * Tests jump menues with more then one same path but maybe differnet titles.
   */
  function testDuplicatePaths() {
    $view = $this->getJumpMenuView();
    $view->set_display();
    $view->init_handlers();

    // Setup a [path] which would leed to "duplicate" paths, but still the shouldn't be used for grouping.
    $view->field['nothing']->options['alter']['text'] = '[path]';
    $view->preview();
    $form = $view->style_plugin->render($view->result);

    // As there is no grouping setup it should be 4 elements.
    $this->assertEqual(count($form['jump']['#options']), 4 + 1);

    // Check that all titles are part of the form as well.
    $options = array_values($form['jump']['#options']);
    foreach ($options as $key => $title) {
      // The first one is the choose label.
      if ($key == 0) {
        continue;
      }
      $this->assertTrue($this->nodeTitles[$key - 1] == trim($title), t('Title @title should appear on the jump list, as we do not filter', array('@title' => $title)));
    }
  }

  function getJumpMenuView() {
    $view = new view;
    $view->name = 'test_jump_menu';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'test_jump_menu';
    $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['access']['type'] = 'perm';
    $handler->display->display_options['cache']['type'] = 'none';
    $handler->display->display_options['query']['type'] = 'views_query';
    $handler->display->display_options['query']['options']['query_comment'] = FALSE;
    $handler->display->display_options['exposed_form']['type'] = 'basic';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['style_plugin'] = 'jump_menu';
    $handler->display->display_options['style_options']['hide'] = 0;
    $handler->display->display_options['style_options']['path'] = 'nothing';
    $handler->display->display_options['style_options']['default_value'] = 0;
    $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']['alter_text'] = 0;
    $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
    $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
    $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
    $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
    $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
    $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
    $handler->display->display_options['fields']['title']['alter']['html'] = 0;
    $handler->display->display_options['fields']['title']['hide_empty'] = 0;
    $handler->display->display_options['fields']['title']['empty_zero'] = 0;
    $handler->display->display_options['fields']['title']['link_to_node'] = 1;
    /* Field: Content: Type */
    $handler->display->display_options['fields']['type']['id'] = 'type';
    $handler->display->display_options['fields']['type']['table'] = 'node';
    $handler->display->display_options['fields']['type']['field'] = 'type';
    $handler->display->display_options['fields']['type']['exclude'] = 1;
    /* Field: Global: Custom text */
    $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
    $handler->display->display_options['fields']['nothing']['table'] = 'views';
    $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
    $handler->display->display_options['fields']['nothing']['alter']['text'] = '[type]';
    $handler->display->display_options['fields']['nothing']['alter']['make_link'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['absolute'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['external'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['replace_spaces'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['trim_whitespace'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['nl2br'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['word_boundary'] = 1;
    $handler->display->display_options['fields']['nothing']['alter']['ellipsis'] = 1;
    $handler->display->display_options['fields']['nothing']['alter']['strip_tags'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['trim'] = 0;
    $handler->display->display_options['fields']['nothing']['alter']['html'] = 0;
    $handler->display->display_options['fields']['nothing']['element_label_colon'] = 1;
    $handler->display->display_options['fields']['nothing']['element_default_classes'] = 1;
    $handler->display->display_options['fields']['nothing']['hide_empty'] = 0;
    $handler->display->display_options['fields']['nothing']['empty_zero'] = 0;
    $handler->display->display_options['fields']['nothing']['hide_alter_empty'] = 0;
    $handler->display->display_options['fields']['nothing']['exclude'] = 1;

    /* 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'] = 0;
    $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

    return $view;
  }
}