From ecf4ec777e019d6c49dc4478f459e2833fb4777f Mon Sep 17 00:00:00 2001
From: Pedro Lozano <peterlozano@gmail.com>
Date: Fri, 15 Jun 2012 17:28:30 +0200
Subject: [PATCH] Issue #1637532: Convert BasicTest to PSR-0.

---
 lib/Drupal/views/Tests/BasicTest.php |  182 ++++++++++++++++++++++++++++++++++
 tests/views_basic.test               |  178 ---------------------------------
 views.info                           |    1 -
 3 files changed, 182 insertions(+), 179 deletions(-)
 create mode 100644 lib/Drupal/views/Tests/BasicTest.php
 delete mode 100644 tests/views_basic.test

diff --git a/lib/Drupal/views/Tests/BasicTest.php b/lib/Drupal/views/Tests/BasicTest.php
new file mode 100644
index 0000000..175d539
--- /dev/null
+++ b/lib/Drupal/views/Tests/BasicTest.php
@@ -0,0 +1,182 @@
+<?php
+
+/**
+ * @file
+ * Definition of ViewsBasicTest.
+ */
+
+namespace Drupal\views\Tests;
+
+use ViewsSqlTest;
+
+/**
+ * Basic test class for Views query builder tests.
+ */
+class BasicTest extends ViewsSqlTest {
+  public static function getInfo() {
+    return array(
+      'name' => 'Basic query test',
+      'description' => 'A basic query test for Views.',
+      'group' => 'Views'
+    );
+  }
+
+  /**
+   * Tests a trivial result set.
+   */
+  public function testSimpleResultSet() {
+    $view = $this->getBasicView();
+
+    // Execute the view.
+    $this->executeView($view);
+
+    // Verify the result.
+    $this->assertEqual(5, count($view->result), t('The number of returned rows match.'));
+    $this->assertIdenticalResultset($view, $this->dataSet(), array(
+      'views_test_name' => 'name',
+      'views_test_age' => 'age',
+    ));
+  }
+
+  /**
+   * Tests filtering of the result set.
+   */
+  public function testSimpleFiltering() {
+    $view = $this->getBasicView();
+
+    // Add a filter.
+    $view->display['default']->handler->override_option('filters', array(
+      'age' => array(
+        'operator' => '<',
+        'value' => array(
+          'value' => '28',
+          'min' => '',
+          'max' => '',
+        ),
+        'group' => '0',
+        'exposed' => FALSE,
+        'expose' => array(
+          'operator' => FALSE,
+          'label' => '',
+        ),
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'relationship' => 'none',
+      ),
+    ));
+
+    // Execute the view.
+    $this->executeView($view);
+
+    // Build the expected result.
+    $dataset = array(
+      array(
+        'id' => 1,
+        'name' => 'John',
+        'age' => 25,
+      ),
+      array(
+        'id' => 2,
+        'name' => 'George',
+        'age' => 27,
+      ),
+      array(
+        'id' => 4,
+        'name' => 'Paul',
+        'age' => 26,
+      ),
+    );
+
+    // Verify the result.
+    $this->assertEqual(3, count($view->result), t('The number of returned rows match.'));
+    $this->assertIdenticalResultSet($view, $dataset, array(
+      'views_test_name' => 'name',
+      'views_test_age' => 'age',
+    ));
+  }
+
+  /**
+   * Tests simple argument.
+   */
+  public function testSimpleArgument() {
+    $view = $this->getBasicView();
+
+    // Add a argument.
+    $view->display['default']->handler->override_option('arguments', array(
+      'age' => array(
+        'default_action' => 'ignore',
+        'style_plugin' => 'default_summary',
+        'style_options' => array(),
+        'wildcard' => 'all',
+        'wildcard_substitution' => 'All',
+        'title' => '',
+        'breadcrumb' => '',
+        'default_argument_type' => 'fixed',
+        'default_argument' => '',
+        'validate_type' => 'none',
+        'validate_fail' => 'not found',
+        'break_phrase' => 0,
+        'not' => 0,
+        'id' => 'age',
+        'table' => 'views_test',
+        'field' => 'age',
+        'validate_user_argument_type' => 'uid',
+        'validate_user_roles' => array(
+          '2' => 0,
+        ),
+        'relationship' => 'none',
+        'default_options_div_prefix' => '',
+        'default_argument_user' => 0,
+        'default_argument_fixed' => '',
+        'default_argument_php' => '',
+        'validate_argument_node_type' => array(
+          'page' => 0,
+          'story' => 0,
+        ),
+        'validate_argument_node_access' => 0,
+        'validate_argument_nid_type' => 'nid',
+        'validate_argument_vocabulary' => array(),
+        'validate_argument_type' => 'tid',
+        'validate_argument_transform' => 0,
+        'validate_user_restrict_roles' => 0,
+        'validate_argument_php' => '',
+      )
+    ));
+
+    $saved_view = clone $view;
+
+    // Execute with a view
+    $view->set_arguments(array(27));
+    $this->executeView($view);
+
+    // Build the expected result.
+    $dataset = array(
+      array(
+        'id' => 2,
+        'name' => 'George',
+        'age' => 27,
+      ),
+    );
+
+    // Verify the result.
+    $this->assertEqual(1, count($view->result), t('The number of returned rows match.'));
+    $this->assertIdenticalResultSet($view, $dataset, array(
+      'views_test_name' => 'name',
+      'views_test_age' => 'age',
+    ));
+
+    // Test "show all" if no argument is present.
+    $view = $saved_view;
+    $this->executeView($view);
+
+    // Build the expected result.
+    $dataset = $this->dataSet();
+
+    $this->assertEqual(5, count($view->result), t('The number of returned rows match.'));
+    $this->assertIdenticalResultSet($view, $dataset, array(
+      'views_test_name' => 'name',
+      'views_test_age' => 'age',
+    ));
+  }
+}
diff --git a/tests/views_basic.test b/tests/views_basic.test
deleted file mode 100644
index 5fc60d8..0000000
--- a/tests/views_basic.test
+++ /dev/null
@@ -1,178 +0,0 @@
-<?php
-
-/**
- * @file
- * Definition of ViewsBasicTest.
- */
-
-/**
- * Basic test class for Views query builder tests.
- */
-class ViewsBasicTest extends ViewsSqlTest {
-  public static function getInfo() {
-    return array(
-      'name' => 'Basic query test',
-      'description' => 'A basic query test for Views.',
-      'group' => 'Views'
-    );
-  }
-
-  /**
-   * Tests a trivial result set.
-   */
-  public function testSimpleResultSet() {
-    $view = $this->getBasicView();
-
-    // Execute the view.
-    $this->executeView($view);
-
-    // Verify the result.
-    $this->assertEqual(5, count($view->result), t('The number of returned rows match.'));
-    $this->assertIdenticalResultset($view, $this->dataSet(), array(
-      'views_test_name' => 'name',
-      'views_test_age' => 'age',
-    ));
-  }
-
-  /**
-   * Tests filtering of the result set.
-   */
-  public function testSimpleFiltering() {
-    $view = $this->getBasicView();
-
-    // Add a filter.
-    $view->display['default']->handler->override_option('filters', array(
-      'age' => array(
-        'operator' => '<',
-        'value' => array(
-          'value' => '28',
-          'min' => '',
-          'max' => '',
-        ),
-        'group' => '0',
-        'exposed' => FALSE,
-        'expose' => array(
-          'operator' => FALSE,
-          'label' => '',
-        ),
-        'id' => 'age',
-        'table' => 'views_test',
-        'field' => 'age',
-        'relationship' => 'none',
-      ),
-    ));
-
-    // Execute the view.
-    $this->executeView($view);
-
-    // Build the expected result.
-    $dataset = array(
-      array(
-        'id' => 1,
-        'name' => 'John',
-        'age' => 25,
-      ),
-      array(
-        'id' => 2,
-        'name' => 'George',
-        'age' => 27,
-      ),
-      array(
-        'id' => 4,
-        'name' => 'Paul',
-        'age' => 26,
-      ),
-    );
-
-    // Verify the result.
-    $this->assertEqual(3, count($view->result), t('The number of returned rows match.'));
-    $this->assertIdenticalResultSet($view, $dataset, array(
-      'views_test_name' => 'name',
-      'views_test_age' => 'age',
-    ));
-  }
-
-  /**
-   * Tests simple argument.
-   */
-  public function testSimpleArgument() {
-    $view = $this->getBasicView();
-
-    // Add a argument.
-    $view->display['default']->handler->override_option('arguments', array(
-      'age' => array(
-        'default_action' => 'ignore',
-        'style_plugin' => 'default_summary',
-        'style_options' => array(),
-        'wildcard' => 'all',
-        'wildcard_substitution' => 'All',
-        'title' => '',
-        'breadcrumb' => '',
-        'default_argument_type' => 'fixed',
-        'default_argument' => '',
-        'validate_type' => 'none',
-        'validate_fail' => 'not found',
-        'break_phrase' => 0,
-        'not' => 0,
-        'id' => 'age',
-        'table' => 'views_test',
-        'field' => 'age',
-        'validate_user_argument_type' => 'uid',
-        'validate_user_roles' => array(
-          '2' => 0,
-        ),
-        'relationship' => 'none',
-        'default_options_div_prefix' => '',
-        'default_argument_user' => 0,
-        'default_argument_fixed' => '',
-        'default_argument_php' => '',
-        'validate_argument_node_type' => array(
-          'page' => 0,
-          'story' => 0,
-        ),
-        'validate_argument_node_access' => 0,
-        'validate_argument_nid_type' => 'nid',
-        'validate_argument_vocabulary' => array(),
-        'validate_argument_type' => 'tid',
-        'validate_argument_transform' => 0,
-        'validate_user_restrict_roles' => 0,
-        'validate_argument_php' => '',
-      )
-    ));
-
-    $saved_view = clone $view;
-
-    // Execute with a view
-    $view->set_arguments(array(27));
-    $this->executeView($view);
-
-    // Build the expected result.
-    $dataset = array(
-      array(
-        'id' => 2,
-        'name' => 'George',
-        'age' => 27,
-      ),
-    );
-
-    // Verify the result.
-    $this->assertEqual(1, count($view->result), t('The number of returned rows match.'));
-    $this->assertIdenticalResultSet($view, $dataset, array(
-      'views_test_name' => 'name',
-      'views_test_age' => 'age',
-    ));
-
-    // Test "show all" if no argument is present.
-    $view = $saved_view;
-    $this->executeView($view);
-
-    // Build the expected result.
-    $dataset = $this->dataSet();
-
-    $this->assertEqual(5, count($view->result), t('The number of returned rows match.'));
-    $this->assertIdenticalResultSet($view, $dataset, array(
-      'views_test_name' => 'name',
-      'views_test_age' => 'age',
-    ));
-  }
-}
diff --git a/views.info b/views.info
index 70f1bf5..494ff7e 100644
--- a/views.info
+++ b/views.info
@@ -273,7 +273,6 @@ files[] = tests/styles/views_plugin_style.test
 files[] = tests/styles/views_plugin_style_unformatted.test
 files[] = tests/views_access.test
 files[] = tests/views_analyze.test
-files[] = tests/views_basic.test
 files[] = tests/views_argument_default.test
 files[] = tests/views_argument_validator.test
 files[] = tests/views_exposed_form.test
-- 
1.7.9

