Commit 02a2a0e4 authored by catch's avatar catch

Issue #1826008 by damiankloip: Fixed Exposed form reset doesn't work.

parent 6a77a6bf
......@@ -312,6 +312,7 @@ function reset_form(&$form, &$form_state) {
$this->view->exposed_data = array();
}
$form_state['redirect'] = current_path();
$form_state['values'] = array();
}
......
......@@ -7,10 +7,12 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\views\Tests\UI\UITestBase;
/**
* Tests exposed forms.
*/
class ExposedFormTest extends PluginTestBase {
class ExposedFormTest extends UITestBase {
/**
* Modules to enable.
......@@ -30,26 +32,38 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
$this->enableViewsTestModule();
$this->drupalCreateContentType(array('type' => 'article'));
$this->drupalCreateContentType(array('type' => 'page'));
// Create some random nodes.
for ($i = 0; $i < 5; $i++) {
$this->drupalCreateNode();
}
}
/**
* Tests whether the reset button works on an expoed form.
*/
public function testResetButton() {
$this->drupalGet('test_reset_button', array('query' => array('type' => 'article')));
// Test that the type has been set.
$this->assertFieldById('edit-type', 'article', 'Article type filter set.');
// Test the reset works.
$this->drupalGet('test_reset_button', array('query' => array('op' => 'Reset')));
$this->assertResponse(200);
// Test the type has been reset.
$this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.');
}
/**
* 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');
$this->drupalGet('test_reset_button');
// Rename the label of the reset button.
$view = views_get_view('test_rename_reset_button');
$view = views_get_view('test_reset_button');
$view->setDisplay();
$exposed_form = $view->display_handler->getOption('exposed_form');
......@@ -61,7 +75,7 @@ public function testRenameResetButton() {
views_invalidate_cache();
// Look whether ther reset button label changed.
$this->drupalGet('test_rename_reset_button');
$this->drupalGet('test_reset_button');
$this->assertResponse(200);
$this->helperButtonHasLabel('edit-reset', $expected_label);
......@@ -71,8 +85,6 @@ public function testRenameResetButton() {
* Tests 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_router_rebuild();
$edit = array();
......
......@@ -44,11 +44,11 @@ display:
position: '0'
page_1:
display_options:
path: test_rename_reset_button
path: test_reset_button
display_plugin: page
display_title: Page
id: page_1
position: '0'
human_name: ''
name: test_rename_reset_button
name: test_reset_button
tag: ''
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment