<?php
-// $Id$
+module_load_include('test', 'views', 'tests/views_query');
+
/**
* @file
* Test exposed forms.
public static function getInfo() {
return array(
'name' => 'Exposed forms',
- 'description' => 'Test exosed forms functionality.',
+ 'description' => 'Test exposed forms functionality.',
'group' => 'Views',
);
}
public function setUp() {
parent::setUp('views', 'views_ui', 'views_test');
module_enable(array('views_ui', 'views_test'));
+ views_include_default_views(TRUE);
}
/**
// 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 = views_get_view('test_rename_reset_button', TRUE);
$view->set_display('default');
$exposed_form = $view->display_handler->get_option('exposed_form');
// 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.'));
+ $this->helperButtonHasLabel('edit-reset', $expected_label);
}
-}
+ /**
+ * Test the admin interface of exposed filter and sort items.
+ */
+ function testExposedAdminUi() {
+ $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
+ $this->drupalLogin($admin_user);
+ menu_rebuild();
+ $edit = array();
+
+ $this->drupalGet('admin/build/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
+ // Be sure that the button is called exposed
+ $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose'));
+
+
+ // Check the validations of the filter handler.
+ $edit = array();
+ $edit['options[expose][identifier]'] = '';
+ $this->drupalPost(NULL, $edit, t('Update'));
+ $this->assertText(t('The identifier is required if the filter is exposed.'));
+
+ $edit = array();
+ $edit['options[expose][identifier]'] = 'value';
+ $this->drupalPost(NULL, $edit, t('Update'));
+ $this->assertText(t('This identifier is not allowed.'));
+
+ // Click the Expose button.
+ $this->drupalPost('admin/build/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose'));
+ // Check the label of the expose button
+ $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide'));
+
+ // Now check the sort criteria.
+ $this->drupalGet('admin/build/views/nojs/config-item/test_exposed_admin_ui/default/sort/created');
+ $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose'));
+ $this->assertNoFieldById('edit-options-expose-label', '', t('Take sure no label field is shown'));
+
+ // Click the Expose button.
+ $this->drupalPost('admin/build/views/nojs/config-item/test_exposed_admin_ui/default/sort/created', $edit, t('Expose'));
+ // Check the label of the expose button
+ $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide'));
+ $this->assertFieldById('edit-options-expose-label', '', t('Take sure a label field is shown'));
+ }
+}