summaryrefslogtreecommitdiff
path: root/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
diff options
context:
space:
mode:
Diffstat (limited to 'sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test')
-rw-r--r--sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test151
1 files changed, 151 insertions, 0 deletions
diff --git a/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test b/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
new file mode 100644
index 000000000..dd4eca0b3
--- /dev/null
+++ b/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
@@ -0,0 +1,151 @@
+<?php
+
+/**
+ * @file
+ * Definition of viewsPluginStyleJumpMenuTest.
+ */
+
+/**
+ * Tests jump menu style functionality.
+ */
+class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
+
+ /**
+ * Stores all created nodes.
+ *
+ * @var array
+ */
+ var $nodes;
+
+ 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;
+ }
+}