From 18f12d9043d41127db756c0540e09bbf130511aa Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Mon, 28 May 2012 20:19:16 +0900
Subject: [PATCH] Issue #1591438 by aspilicious: Convert forum tests to PSR-0.

---
 core/modules/forum/forum.info                 |  1 -
 .../lib/Drupal/forum/Tests/ForumIndexTest.php | 72 +++++++++++++++++++
 .../Drupal/forum/Tests/ForumTest.php}         | 68 ++----------------
 3 files changed, 76 insertions(+), 65 deletions(-)
 create mode 100644 core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
 rename core/modules/forum/{forum.test => lib/Drupal/forum/Tests/ForumTest.php} (92%)

diff --git a/core/modules/forum/forum.info b/core/modules/forum/forum.info
index f202f9e0d57d..887ed93ddf76 100644
--- a/core/modules/forum/forum.info
+++ b/core/modules/forum/forum.info
@@ -6,6 +6,5 @@ dependencies[] = comment
 package = Core
 version = VERSION
 core = 8.x
-files[] = forum.test
 configure = admin/structure/forum
 stylesheets[all][] = forum.css
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
new file mode 100644
index 000000000000..e7f937dcd327
--- /dev/null
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
@@ -0,0 +1,72 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\forum\Tests\ForumIndexTest.
+ */
+
+namespace Drupal\forum\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests the forum index listing.
+ */
+class ForumIndexTest extends WebTestBase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Forum index',
+      'description' => 'Tests the forum index listing.',
+      'group' => 'Forum',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('taxonomy', 'comment', 'forum');
+
+    // Create a test user.
+    $web_user = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes'));
+    $this->drupalLogin($web_user);
+  }
+
+  /**
+   * Tests the forum index for published and unpublished nodes.
+   */
+  function testForumIndexStatus() {
+
+    $langcode = LANGUAGE_NOT_SPECIFIED;
+
+    // The forum ID to use.
+    $tid = 1;
+
+    // Create a test node.
+    $title = $this->randomName(20);
+    $edit = array(
+      "title" => $title,
+      "body[$langcode][0][value]" => $this->randomName(200),
+    );
+
+    // Create the forum topic, preselecting the forum ID via a URL parameter.
+    $this->drupalPost('node/add/forum/' . $tid, $edit, t('Save'));
+
+    // Check that the node exists in the database.
+    $node = $this->drupalGetNodeByTitle($title);
+    $this->assertTrue(!empty($node), 'New forum node found in database.');
+
+    // Verify that the node appears on the index.
+    $this->drupalGet('forum/' . $tid);
+    $this->assertText($title, 'Published forum topic appears on index.');
+
+    // Unpublish the node.
+    $edit = array(
+      'status' => FALSE,
+    );
+    $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save'));
+    $this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.');
+
+    // Verify that the node no longer appears on the index.
+    $this->drupalGet('forum/' . $tid);
+    $this->assertNoText($title, 'Unpublished forum topic no longer appears on index.');
+  }
+}
diff --git a/core/modules/forum/forum.test b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
similarity index 92%
rename from core/modules/forum/forum.test
rename to core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
index 45610920b760..49f136da8332 100644
--- a/core/modules/forum/forum.test
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
@@ -2,13 +2,15 @@
 
 /**
  * @file
- * Tests for forum.module.
+ * Definition of Drupal\forum\Tests\ForumTest.
  */
 
+namespace Drupal\forum\Tests;
+
 use Drupal\node\Node;
 use Drupal\simpletest\WebTestBase;
 
-class ForumTestCase extends WebTestBase {
+class ForumTest extends WebTestBase {
   protected $admin_user;
   protected $edit_own_topics_user;
   protected $edit_any_topics_user;
@@ -591,65 +593,3 @@ private function viewForumTopics($nids) {
     }
   }
 }
-
-/**
- * Tests the forum index listing.
- */
-class ForumIndexTestCase extends WebTestBase {
-
-  public static function getInfo() {
-    return array(
-      'name' => 'Forum index',
-      'description' => 'Tests the forum index listing.',
-      'group' => 'Forum',
-    );
-  }
-
-  function setUp() {
-    parent::setUp('taxonomy', 'comment', 'forum');
-
-    // Create a test user.
-    $web_user = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes'));
-    $this->drupalLogin($web_user);
-  }
-
-  /**
-   * Tests the forum index for published and unpublished nodes.
-   */
-  function testForumIndexStatus() {
-
-    $langcode = LANGUAGE_NOT_SPECIFIED;
-
-    // The forum ID to use.
-    $tid = 1;
-
-    // Create a test node.
-    $title = $this->randomName(20);
-    $edit = array(
-      "title" => $title,
-      "body[$langcode][0][value]" => $this->randomName(200),
-    );
-
-    // Create the forum topic, preselecting the forum ID via a URL parameter.
-    $this->drupalPost('node/add/forum/' . $tid, $edit, t('Save'));
-
-    // Check that the node exists in the database.
-    $node = $this->drupalGetNodeByTitle($title);
-    $this->assertTrue(!empty($node), 'New forum node found in database.');
-
-    // Verify that the node appears on the index.
-    $this->drupalGet('forum/' . $tid);
-    $this->assertText($title, 'Published forum topic appears on index.');
-
-    // Unpublish the node.
-    $edit = array(
-      'status' => FALSE,
-    );
-    $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save'));
-    $this->assertText(t('Access denied'), 'Unpublished node is no longer accessible.');
-
-    // Verify that the node no longer appears on the index.
-    $this->drupalGet('forum/' . $tid);
-    $this->assertNoText($title, 'Unpublished forum topic no longer appears on index.');
-  }
-}
-- 
GitLab