From eb8bc6b1b9fe12aa68e411046c9f06e01c313941 Mon Sep 17 00:00:00 2001
From: Pedro Lozano <peterlozano@gmail.com>
Date: Fri, 15 Jun 2012 17:05:41 +0200
Subject: [PATCH 2/2] Issue #1637532: Convert ExposedForm test to PSR-0.

---
 lib/Drupal/views/Tests/ExposedFormTest.php |  104 ++++++++++++++++++++++++++++
 tests/views_exposed_form.test              |  100 --------------------------
 views.info                                 |    1 -
 3 files changed, 104 insertions(+), 101 deletions(-)
 create mode 100644 lib/Drupal/views/Tests/ExposedFormTest.php
 delete mode 100644 tests/views_exposed_form.test

diff --git a/lib/Drupal/views/Tests/ExposedFormTest.php b/lib/Drupal/views/Tests/ExposedFormTest.php
new file mode 100644
index 0000000..ebd9097
--- /dev/null
+++ b/lib/Drupal/views/Tests/ExposedFormTest.php
@@ -0,0 +1,104 @@
+<?php
+
+/**
+ * @file
+ * Definition of ViewsExposedFormTest.
+ */
+
+namespace Drupal\views\Tests;
+
+use ViewsSqlTest;
+
+/**
+ * Tests exposed forms.
+ */
+class ExposedFormTest extends ViewsSqlTest {
+  public static function getInfo() {
+    return array(
+      'name' => 'Exposed forms',
+      'description' => 'Test exposed forms functionality.',
+      'group' => 'Views Plugins',
+    );
+  }
+
+  public function setUp() {
+    parent::setUp('views_ui');
+    module_enable(array('views_ui'));
+    // @TODO Figure out why it's required to clear the cache here.
+    views_module_include('views_default', TRUE);
+    views_get_all_views(TRUE);
+    menu_router_rebuild();
+  }
+
+  /**
+   * 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');
+
+    $this->helperButtonHasLabel('edit-reset', $expected_label);
+  }
+
+  /**
+   * 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();
+
+    $this->drupalGet('admin/structure/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 filter'));
+
+    // Click the Expose filter button.
+    $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
+    // Check the label of the expose button
+    $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter'));
+
+    // Check the validations of the filter handler.
+    $edit = array();
+    $edit['options[expose][identifier]'] = '';
+    $this->drupalPost(NULL, $edit, t('Apply'));
+    $this->assertText(t('The identifier is required if the filter is exposed.'));
+
+    $edit = array();
+    $edit['options[expose][identifier]'] = 'value';
+    $this->drupalPost(NULL, $edit, t('Apply'));
+    $this->assertText(t('This identifier is not allowed.'));
+
+    // Now check the sort criteria.
+    $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created');
+    $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose sort'));
+    $this->assertNoFieldById('edit-options-expose-label', '', t('Make sure no label field is shown'));
+
+    // Click the Expose sort button.
+    $edit = array();
+    $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
+    // Check the label of the expose button
+    $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
+    $this->assertFieldById('edit-options-expose-label', '', t('Make sure a label field is shown'));
+  }
+}
diff --git a/tests/views_exposed_form.test b/tests/views_exposed_form.test
deleted file mode 100644
index 3b2933b..0000000
--- a/tests/views_exposed_form.test
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-
-/**
- * @file
- * Definition of ViewsExposedFormTest.
- */
-
-/**
- * Tests exposed forms.
- */
-class ViewsExposedFormTest extends ViewsSqlTest {
-  public static function getInfo() {
-    return array(
-      'name' => 'Exposed forms',
-      'description' => 'Test exposed forms functionality.',
-      'group' => 'Views Plugins',
-    );
-  }
-
-  public function setUp() {
-    parent::setUp('views_ui');
-    module_enable(array('views_ui'));
-    // @TODO Figure out why it's required to clear the cache here.
-    views_module_include('views_default', TRUE);
-    views_get_all_views(TRUE);
-    menu_router_rebuild();
-  }
-
-  /**
-   * 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');
-
-    $this->helperButtonHasLabel('edit-reset', $expected_label);
-  }
-
-  /**
-   * 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();
-
-    $this->drupalGet('admin/structure/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 filter'));
-
-    // Click the Expose filter button.
-    $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
-    // Check the label of the expose button
-    $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter'));
-
-    // Check the validations of the filter handler.
-    $edit = array();
-    $edit['options[expose][identifier]'] = '';
-    $this->drupalPost(NULL, $edit, t('Apply'));
-    $this->assertText(t('The identifier is required if the filter is exposed.'));
-
-    $edit = array();
-    $edit['options[expose][identifier]'] = 'value';
-    $this->drupalPost(NULL, $edit, t('Apply'));
-    $this->assertText(t('This identifier is not allowed.'));
-
-    // Now check the sort criteria.
-    $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created');
-    $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose sort'));
-    $this->assertNoFieldById('edit-options-expose-label', '', t('Make sure no label field is shown'));
-
-    // Click the Expose sort button.
-    $edit = array();
-    $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
-    // Check the label of the expose button
-    $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
-    $this->assertFieldById('edit-options-expose-label', '', t('Make sure a label field is shown'));
-  }
-}
diff --git a/views.info b/views.info
index ebc2b18..12f5eb2 100644
--- a/views.info
+++ b/views.info
@@ -275,7 +275,6 @@ files[] = tests/views_access.test
 files[] = tests/views_basic.test
 files[] = tests/views_argument_default.test
 files[] = tests/views_argument_validator.test
-files[] = tests/views_exposed_form.test
 files[] = tests/field/views_fieldapi.test
 files[] = tests/views_groupby.test
 files[] = tests/views_handlers.test
-- 
1.7.9

