summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wehner2010-02-07 13:08:05 (GMT)
committer Daniel Wehner2010-02-07 13:08:05 (GMT)
commit8f1f40b862b23328798441f84e9b768689a4e2f4 (patch)
tree60be02a59834bf52b525ee32e36b832d6b818fbd
parent53d081873cfa5b9eca7bc26571c054dbcedb716e (diff)
by dereine: add testing for renaming a exposed form reset button
-rw-r--r--tests/views_exposed_form.test54
-rw-r--r--tests/views_test.views_default.inc69
2 files changed, 123 insertions, 0 deletions
diff --git a/tests/views_exposed_form.test b/tests/views_exposed_form.test
new file mode 100644
index 0000000..b7ffb25
--- /dev/null
+++ b/tests/views_exposed_form.test
@@ -0,0 +1,54 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Test exposed forms.
+ */
+class ViewsExposedFormTest extends ViewsSqlTest {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Exposed forms',
+ 'description' => 'Test exosed forms functionality.',
+ 'group' => 'Views',
+ );
+ }
+
+ public function setUp() {
+ parent::setUp('views', 'views_ui', 'views_test');
+ module_enable(array('views_ui', 'views_test'));
+ }
+
+ /**
+ * Tests, whether and how the reset button can be renamed.
+ */
+ public function testRenameResetButton() {
+ $account = $this->drupalCreateUser();
+ $this->drupalLogin($account);
+ // Create some random nodes.
+ for ($i = 0; $i < 5; $i++) {
+ $this->drupalCreateNode();
+ }
+ // Look at the page and check the label "reset".
+ $this->drupalGet('test_rename_reset_button');
+ // Rename the label of the reset button.
+ $view = views_get_view('test_rename_reset_button');
+ $view->set_display('default');
+
+ $exposed_form = $view->display_handler->get_option('exposed_form');
+ $exposed_form['options']['reset_button_label'] = $expected_label = $this->randomName();
+ $exposed_form['options']['reset_button'] = TRUE;
+ $view->display_handler->set_option('exposed_form', $exposed_form);
+ $view->save();
+
+ views_invalidate_cache();
+
+ // Look whether ther reset button label changed.
+ $this->drupalGet('test_rename_reset_button');
+
+ $xpath = '//input[@id="edit-reset"]';
+ $element = $this->xpath($xpath);
+ $label = $element[0]['value'];
+ $this->assertEqual($label, $expected_label, t('Label of the rest button changed.'));
+ }
+}
+
diff --git a/tests/views_test.views_default.inc b/tests/views_test.views_default.inc
new file mode 100644
index 0000000..e2751e5
--- /dev/null
+++ b/tests/views_test.views_default.inc
@@ -0,0 +1,69 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Test views
+ */
+
+/**
+ * Implements hook_views_default_views().
+ */
+function views_test_views_default_views() {
+ $view = new view;
+ $view->name = 'test_views_groupby_save';
+ $view->description = '';
+ $view->tag = '';
+ $view->view_php = '';
+ $view->base_table = 'node';
+ $view->is_cacheable = FALSE;
+ $view->api_version = 2;
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+ /* Display: Defaults */
+ $handler = $view->new_display('default', 'Defaults', 'default');
+ $handler->display->display_options['access']['type'] = 'none';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['pager']['type'] = 'none';
+ $handler->display->display_options['style_plugin'] = 'default';
+ $handler->display->display_options['row_plugin'] = 'fields';
+
+ $views[$view->name] = $view;
+
+ $view = new view;
+ $view->name = 'test_rename_reset_button';
+ $view->description = '';
+ $view->tag = '';
+ $view->view_php = '';
+ $view->base_table = 'node';
+ $view->is_cacheable = FALSE;
+ $view->api_version = 2;
+ $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+
+ /* Display: Defaults */
+ $handler = $view->new_display('default', 'Defaults', 'default');
+ $handler->display->display_options['access']['type'] = 'none';
+ $handler->display->display_options['cache']['type'] = 'none';
+ $handler->display->display_options['exposed_form']['type'] = 'basic';
+ $handler->display->display_options['exposed_form']['options']['reset_button'] = TRUE;
+ $handler->display->display_options['pager']['type'] = 'full';
+ $handler->display->display_options['style_plugin'] = 'default';
+ $handler->display->display_options['row_plugin'] = 'node';
+ $handler->display->display_options['row_options']['links'] = 1;
+ $handler->display->display_options['row_options']['comments'] = 0;
+ /* Filter: Node: 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']['exposed'] = TRUE;
+ $handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op';
+ $handler->display->display_options['filters']['type']['expose']['label'] = 'Node: Type';
+
+ /* Display: Page */
+ $handler = $view->new_display('page', 'Page', 'page_1');
+ $handler->display->display_options['path'] = 'test_rename_reset_button';
+
+ $views[$view->name] = $view;
+
+ return $views;
+}