diff --git a/core/modules/forum/css/forum.module.css b/core/modules/forum/css/forum.module.css index 6f2cece..09262d5 100644 --- a/core/modules/forum/css/forum.module.css +++ b/core/modules/forum/css/forum.module.css @@ -15,7 +15,7 @@ #forum td.pager { white-space: nowrap; } -#forum .icon{ +#forum .icon { background-image: url(../../../misc/forum-icons.png); background-repeat: no-repeat; float: left; /* LTR */ diff --git a/core/modules/forum/forum.views.inc b/core/modules/forum/forum.views.inc index fa7174f..e86f1be 100644 --- a/core/modules/forum/forum.views.inc +++ b/core/modules/forum/forum.views.inc @@ -86,7 +86,6 @@ function forum_views_data() { ), ); - $data['forum_index']['created'] = array( 'title' => t('Post date'), 'help' => t('The date the content was posted.'), @@ -94,7 +93,7 @@ function forum_views_data() { 'id' => 'date', ), 'sort' => array( - 'id' => 'date' + 'id' => 'date', ), 'filter' => array( 'id' => 'date', diff --git a/core/modules/forum/src/Form/ForumForm.php b/core/modules/forum/src/Form/ForumForm.php index 4641781..2f8c67e 100644 --- a/core/modules/forum/src/Form/ForumForm.php +++ b/core/modules/forum/src/Form/ForumForm.php @@ -86,13 +86,25 @@ public function save(array $form, FormStateInterface $form_state) { switch ($status) { case SAVED_NEW: drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType))); - $this->logger('forum')->notice('Created new @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link)); + $this->logger('forum')->notice('Created new @type %term.', + array( + '%term' => $term->getName(), + '@type' => $this->forumFormType, + 'link' => $link, + ) + ); $form_state->setValue('tid', $term->id()); break; case SAVED_UPDATED: drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->getName(), '@type' => $this->forumFormType))); - $this->logger('forum')->notice('Updated @type %term.', array('%term' => $term->getName(), '@type' => $this->forumFormType, 'link' => $link)); + $this->logger('forum')->notice('Updated @type %term.', + array( + '%term' => $term->getName(), + '@type' => $this->forumFormType, + 'link' => $link, + ) + ); break; } diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php index 24f5142..cb8d263 100644 --- a/core/modules/forum/src/Form/Overview.php +++ b/core/modules/forum/src/Form/Overview.php @@ -91,7 +91,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#submit'] = array('::submitForm'); $form['terms']['#empty'] = $this->t('No containers or forums available. Add container or Add forum.', array( '@container' => $this->url('forum.add_container'), - '@forum' => $this->url('forum.add_forum') + '@forum' => $this->url('forum.add_forum'), )); return $form; } diff --git a/core/modules/forum/src/ForumIndexStorage.php b/core/modules/forum/src/ForumIndexStorage.php index c7fa74f..c4e7d87 100644 --- a/core/modules/forum/src/ForumIndexStorage.php +++ b/core/modules/forum/src/ForumIndexStorage.php @@ -28,7 +28,7 @@ class ForumIndexStorage implements ForumIndexStorageInterface { * @param \Drupal\Core\Database\Connection $database * The current database connection. */ - function __construct(Connection $database) { + public function __construct(Connection $database) { $this->database = $database; } @@ -108,7 +108,7 @@ public function updateIndex(NodeInterface $node) { ':status' => CommentInterface::PUBLISHED, ))->fetchObject(); $this->database->update('forum_index') - ->fields( array( + ->fields(array( 'comment_count' => $count, 'last_comment_timestamp' => $last_reply->created, )) @@ -117,9 +117,9 @@ public function updateIndex(NodeInterface $node) { } else { // Comments do not exist. - // @todo This should be actually filtering on the desired node language + // @todo This should be actually filtering on the desired node language. $this->database->update('forum_index') - ->fields( array( + ->fields(array( 'comment_count' => 0, 'last_comment_timestamp' => $node->getCreatedTime(), )) @@ -132,8 +132,17 @@ public function updateIndex(NodeInterface $node) { * {@inheritdoc} */ public function createIndex(NodeInterface $node) { - $query = $this->database->insert('forum_index') - ->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); + $query = $this->database->insert('forum_index')->fields( + array( + 'nid', + 'title', + 'tid', + 'sticky', + 'created', + 'comment_count', + 'last_comment_timestamp', + ) + ); foreach ($node->getTranslationLanguages() as $langcode => $language) { $translation = $node->getTranslation($langcode); foreach ($translation->taxonomy_forums as $item) { diff --git a/core/modules/forum/src/ForumIndexStorageInterface.php b/core/modules/forum/src/ForumIndexStorageInterface.php index 0df178f..d310dc9 100644 --- a/core/modules/forum/src/ForumIndexStorageInterface.php +++ b/core/modules/forum/src/ForumIndexStorageInterface.php @@ -3,6 +3,7 @@ * @file * Contains */ + namespace Drupal\forum; use Drupal\node\NodeInterface; diff --git a/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php index ec410de..5690181 100644 --- a/core/modules/forum/src/ForumManager.php +++ b/core/modules/forum/src/ForumManager.php @@ -22,10 +22,13 @@ */ class ForumManager implements ForumManagerInterface { use StringTranslationTrait; + // @codingStandardsIgnoreStart + // A false positive error on these lines. use DependencySerializationTrait { __wakeup as defaultWakeup; __sleep as defaultSleep; } + // @codingStandardsIgnoreEnd /** * Forum sort order, newest first. @@ -189,7 +192,7 @@ public function getTopics($tid, AccountInterface $account) { 'cid', 'last_comment_uid', 'last_comment_timestamp', - 'comment_count' + 'comment_count', )); $query->join('forum_index', 'f', 'f.nid = n.nid'); @@ -229,8 +232,8 @@ public function getTopics($tid, AccountInterface $account) { $first_new_found = FALSE; foreach ($result as $topic) { if ($account->isAuthenticated()) { - // A forum is new if the topic is new, or if there are new comments since - // the user's last visit. + // A forum is new if the topic is new, or if there are new comments + // since the user's last visit. if ($topic->forum_tid != $tid) { $topic->new = 0; } @@ -241,7 +244,8 @@ public function getTopics($tid, AccountInterface $account) { } } else { - // Do not track "new replies" status for topics if the user is anonymous. + // Do not track "new replies" status for topics if the user is + // anonymous. $topic->new_replies = 0; $topic->new = 0; } @@ -440,7 +444,7 @@ public function getIndex() { 'container' => 1, 'parents' => array(), 'isIndex' => TRUE, - 'vid' => $vid + 'vid' => $vid, )); // Load the tree below. diff --git a/core/modules/forum/src/ForumManagerInterface.php b/core/modules/forum/src/ForumManagerInterface.php index 874ede7..e7428c6 100644 --- a/core/modules/forum/src/ForumManagerInterface.php +++ b/core/modules/forum/src/ForumManagerInterface.php @@ -82,7 +82,7 @@ public function getParents($tid); public function checkNodeType(NodeInterface $node); /** - * Calculates the number of new posts in a forum that the user has not yet read. + * Calculates the nb of new posts in a forum that the user has not yet read. * * Nodes are new if they are newer than HISTORY_READ_LIMIT. * @@ -91,7 +91,7 @@ public function checkNodeType(NodeInterface $node); * @param int $uid * The user ID. * - * @return + * @return int * The number of new posts in the forum that have not been read by the user. */ public function unreadTopics($term, $uid); diff --git a/core/modules/forum/src/ForumSettingsForm.php b/core/modules/forum/src/ForumSettingsForm.php index 77f176d..f6c91a7 100644 --- a/core/modules/forum/src/ForumSettingsForm.php +++ b/core/modules/forum/src/ForumSettingsForm.php @@ -28,7 +28,12 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('forum.settings'); - $options = array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500); + $options = array( + 5, 10, 15, 20, 25, + 30, 35, 40, 50, 60, + 80, 100, 150, 200, 250, + 300, 350, 400, 500, + ); $form['forum_hot_topic'] = array( '#type' => 'select', '#title' => $this->t('Hot topic threshold'), @@ -48,7 +53,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { 1 => $this->t('Date - newest first'), 2 => $this->t('Date - oldest first'), 3 => $this->t('Posts - most active first'), - 4 => $this->t('Posts - least active first') + 4 => $this->t('Posts - least active first'), ); $form['forum_order'] = array( '#type' => 'radios', diff --git a/core/modules/forum/src/Tests/ForumBlockTest.php b/core/modules/forum/src/Tests/ForumBlockTest.php index 78e1c44..24330c8 100644 --- a/core/modules/forum/src/Tests/ForumBlockTest.php +++ b/core/modules/forum/src/Tests/ForumBlockTest.php @@ -29,6 +29,9 @@ class ForumBlockTest extends WebTestBase { */ protected $adminUser; + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); @@ -56,7 +59,6 @@ public function testNewForumTopicsBlock() { // Create 5 forum topics. $topics = $this->createForumTopics(); - $this->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.'); $this->assertLinkByHref('forum', 0, 'New forum topics block has a "more"-link.'); diff --git a/core/modules/forum/src/Tests/ForumIndexTest.php b/core/modules/forum/src/Tests/ForumIndexTest.php index b9ee537..40a28c9 100644 --- a/core/modules/forum/src/Tests/ForumIndexTest.php +++ b/core/modules/forum/src/Tests/ForumIndexTest.php @@ -23,18 +23,28 @@ class ForumIndexTest extends WebTestBase { */ public static $modules = array('taxonomy', 'comment', 'forum'); + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); // Create a test user. - $web_user = $this->drupalCreateUser(array('create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes')); + $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() { + public function testForumIndexStatus() { // The forum ID to use. $tid = 1; diff --git a/core/modules/forum/src/Tests/ForumNodeAccessTest.php b/core/modules/forum/src/Tests/ForumNodeAccessTest.php index 34ddd35..6401b48 100644 --- a/core/modules/forum/src/Tests/ForumNodeAccessTest.php +++ b/core/modules/forum/src/Tests/ForumNodeAccessTest.php @@ -21,8 +21,19 @@ class ForumNodeAccessTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'comment', 'forum', 'taxonomy', 'tracker', 'node_access_test', 'block'); + public static $modules = array( + 'node', + 'comment', + 'forum', + 'taxonomy', + 'tracker', + 'node_access_test', + 'block', + ); + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); node_access_rebuild(); @@ -36,11 +47,18 @@ protected function setUp() { * Adds both active forum topics and new forum topics blocks to the sidebar. * Tests to ensure private node/public node access is respected on blocks. */ - function testForumNodeAccess() { + public function testForumNodeAccess() { // Create some users. $access_user = $this->drupalCreateUser(array('node test view')); $no_access_user = $this->drupalCreateUser(); - $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules', 'administer blocks', 'create forum content')); + $admin_user = $this->drupalCreateUser( + array( + 'access administration pages', + 'administer modules', + 'administer blocks', + 'create forum content', + ) + ); $this->drupalLogin($admin_user); @@ -65,7 +83,6 @@ function testForumNodeAccess() { $public_node = $this->drupalGetNodeByTitle($public_node_title); $this->assertTrue(!empty($public_node), 'New public forum node found in database.'); - // Enable the new and active forum blocks. $this->drupalPlaceBlock('forum_active_block'); $this->drupalPlaceBlock('forum_new_block'); diff --git a/core/modules/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php index 8ebdb81..bac885d 100644 --- a/core/modules/forum/src/Tests/ForumTest.php +++ b/core/modules/forum/src/Tests/ForumTest.php @@ -24,27 +24,35 @@ class ForumTest extends WebTestBase { * * @var array */ - public static $modules = array('taxonomy', 'comment', 'forum', 'node', 'block', 'menu_ui', 'help'); + public static $modules = array( + 'taxonomy', + 'comment', + 'forum', + 'node', + 'block', + 'menu_ui', + 'help', + ); /** * A user with various administrative privileges. */ - protected $admin_user; + protected $adminUser; /** * A user that can create forum topics and edit its own topics. */ - protected $edit_own_topics_user; + protected $editOwnTopicsUser; /** * A user that can create, edit, and delete forum topics. */ - protected $edit_any_topics_user; + protected $editAnyTopicsUser; /** * A user with no special privileges. */ - protected $web_user; + protected $webUser; /** * An array representing a forum container. @@ -59,18 +67,21 @@ class ForumTest extends WebTestBase { /** * An array representing a root forum. */ - protected $root_forum; + protected $rootForum; /** * An array of forum topic node IDs. */ protected $nids; + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); // Create users. - $this->admin_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'access administration pages', 'administer modules', 'administer blocks', @@ -80,18 +91,18 @@ protected function setUp() { 'create forum content', 'access comments', )); - $this->edit_any_topics_user = $this->drupalCreateUser(array( + $this->editAnyTopicsUser = $this->drupalCreateUser(array( 'access administration pages', 'create forum content', 'edit any forum content', 'delete any forum content', )); - $this->edit_own_topics_user = $this->drupalCreateUser(array( + $this->editOwnTopicsUser = $this->drupalCreateUser(array( 'create forum content', 'edit own forum content', 'delete own forum content', )); - $this->web_user = $this->drupalCreateUser(); + $this->webUser = $this->drupalCreateUser(); $this->post_comment_user = $this->drupalCreateUser(array( 'administer content types', 'create forum content', @@ -105,35 +116,34 @@ protected function setUp() { /** * Tests forum functionality through the admin and user interfaces. */ - function testForum() { - //Check that the basic forum install creates a default forum topic + public function testForum() { + // Check that the basic forum install creates a default forum topic. $this->drupalGet("/forum"); - // Look for the "General discussion" default forum + // Look for the "General discussion" default forum. $this->assertText(t("General discussion"), "Found the default forum at the /forum listing"); // Do the admin tests. - $this->doAdminTests($this->admin_user); + $this->doAdminTests($this->adminUser); $this->generateForumTopics(); // Login an unprivileged user to view the forum topics and generate an // active forum topics list. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Verify that this user is shown a message that they may not post content. $this->drupalGet('forum/' . $this->forum['tid']); // @todo Restore test coverage in https://www.drupal.org/node/1853072. - //$this->assertText(t('You are not allowed to post new content in the forum'), "Authenticated user without permission to post forum content is shown message in local tasks to that effect."); - + // $this->assertText(t('You are not allowed to post new content in the forum'), "Authenticated user without permission to post forum content is shown message in local tasks to that effect."); // Log in, and do basic tests for a user with permission to edit any forum // content. - $this->doBasicTests($this->edit_any_topics_user, TRUE); + $this->doBasicTests($this->editAnyTopicsUser, TRUE); // Create a forum node authored by this user. $any_topics_user_node = $this->createForumTopic($this->forum, FALSE); // Log in, and do basic tests for a user with permission to edit only its // own forum content. - $this->doBasicTests($this->edit_own_topics_user, FALSE); + $this->doBasicTests($this->editOwnTopicsUser, FALSE); // Create a forum node authored by this user. $own_topics_user_node = $this->createForumTopic($this->forum, FALSE); // Verify that this user cannot edit forum content authored by another user. @@ -146,7 +156,7 @@ function testForum() { $this->assertLink(t('Add new Forum topic')); // Login a user with permission to edit any forum content. - $this->drupalLogin($this->edit_any_topics_user); + $this->drupalLogin($this->editAnyTopicsUser); // Verify that this user can edit forum content authored by another user. $this->verifyForums($own_topics_user_node, TRUE); @@ -163,7 +173,7 @@ function testForum() { $this->assertEqual($topics, '6', 'Number of topics found.'); // Verify the number of unread topics. - $unread_topics = $this->container->get('forum_manager')->unreadTopics($this->forum['tid'], $this->edit_any_topics_user->id()); + $unread_topics = $this->container->get('forum_manager')->unreadTopics($this->forum['tid'], $this->editAnyTopicsUser->id()); $unread_topics = format_plural($unread_topics, '1 new post', '@count new posts'); $xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="topics"]//a', $forum_arg); $this->assertFieldByXPath($xpath, $unread_topics, 'Number of unread topics found.'); @@ -176,7 +186,13 @@ function testForum() { $this->assertFieldByXPath($xpath, '6', 'Number of posts found.'); // Test loading multiple forum nodes on the front page. - $this->drupalLogin($this->drupalCreateUser(array('administer content types', 'create forum content', 'post comments'))); + $this->drupalLogin($this->drupalCreateUser( + array( + 'administer content types', + 'create forum content', + 'post comments') + ) + ); $this->drupalPostForm('admin/structure/types/manage/forum', array('options[promote]' => 'promote'), t('Save content type')); $this->createForumTopic($this->forum, FALSE); $this->createForumTopic($this->forum, FALSE); @@ -190,7 +206,7 @@ function testForum() { $this->assertResponse(200); // Test editing a forum topic that has a comment. - $this->drupalLogin($this->edit_any_topics_user); + $this->drupalLogin($this->editAnyTopicsUser); $this->drupalGet('forum/' . $this->forum['tid']); $this->drupalPostForm('node/' . $node->id() . '/edit', array(), t('Save')); $this->assertResponse(200); @@ -211,7 +227,7 @@ function testForum() { * Verifies that forum nodes are not created without choosing "forum" from the * select list. */ - function testAddOrphanTopic() { + public function testAddOrphanTopic() { // Must remove forum topics to test creating orphan topics. $vid = \Drupal::config('forum.settings')->get('vocabulary'); $tids = \Drupal::entityQuery('taxonomy_term') @@ -223,7 +239,7 @@ function testAddOrphanTopic() { $edit = array(); $edit['title[0][value]'] = $this->randomMachineName(10); $edit['body[0][value]'] = $this->randomMachineName(120); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalPostForm('node/add/forum', $edit, t('Save')); $nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField(); @@ -278,7 +294,7 @@ private function doAdminTests($user) { // Delete this second forum. $this->deleteForum($this->delete_forum['tid']); // Create forum at the top (root) level. - $this->root_forum = $this->createForum('forum'); + $this->rootForum = $this->createForum('forum'); // Test vocabulary form alterations. $this->drupalGet('admin/structure/taxonomy/manage/forums'); @@ -316,7 +332,7 @@ private function doAdminTests($user) { /** * Edits the forum taxonomy. */ - function editForumVocabulary() { + protected function editForumVocabulary() { // Backup forum taxonomy. $vid = \Drupal::config('forum.settings')->get('vocabulary'); $original_vocabulary = entity_load('taxonomy_vocabulary', $vid); @@ -351,15 +367,15 @@ function editForumVocabulary() { /** * Creates a forum container or a forum. * - * @param $type + * @param string $type * The forum type (forum container or forum). - * @param $parent + * @param array $parent * The forum parent. This defaults to 0, indicating a root forum. * - * @return + * @return object * The created taxonomy term data. */ - function createForum($type, $parent = 0) { + public function createForum($type, $parent = 0) { // Generate a random name/description. $name = $this->randomMachineName(10); $description = $this->randomMachineName(100); @@ -378,13 +394,17 @@ function createForum($type, $parent = 0) { $this->assertRaw( t( 'Created new @type %term.', - array('%term' => $name, '@type' => t($type)) + array('%term' => $name, '@type' => t('!type', array('!type' => $type))) ), format_string('@type was created', array('@type' => ucfirst($type))) ); // Verify forum. - $term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", array(':vid' => \Drupal::config('forum.settings')->get('vocabulary'), ':name' => $name, ':desc' => $description))->fetchAssoc(); + $term = db_query("SELECT * FROM {taxonomy_term_field_data} t WHERE t.vid = :vid AND t.name = :name AND t.description__value = :desc AND t.default_langcode = 1", + array( + ':vid' => \Drupal::config('forum.settings')->get('vocabulary'), + ':name' => $name, ':desc' => $description) + )->fetchAssoc(); $this->assertTrue(!empty($term), 'The ' . $type . ' exists in the database'); // Verify forum hierarchy. @@ -400,10 +420,10 @@ function createForum($type, $parent = 0) { /** * Deletes a forum. * - * @param $tid + * @param int $tid * The forum ID. */ - function deleteForum($tid) { + protected function deleteForum($tid) { // Delete the forum. $this->drupalGet('admin/structure/forum/edit/forum/' . $tid); $this->clickLink(t('Delete')); @@ -420,9 +440,9 @@ function deleteForum($tid) { /** * Runs basic tests on the indicated user. * - * @param $user + * @param \Drupal\Core\Session\AccountInterface $user * The logged in user. - * @param $admin + * @param bool $admin * User has 'access administration pages' privilege. */ private function doBasicTests($user, $admin) { @@ -439,9 +459,9 @@ private function doBasicTests($user, $admin) { /** * Tests a forum with a new post displays properly. */ - function testForumWithNewPost() { + public function testForumWithNewPost() { // Login as the first user. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Create a forum container. $this->forumContainer = $this->createForum('container'); // Create a forum. @@ -464,7 +484,7 @@ function testForumWithNewPost() { $this->assertFieldByName('comment_body[0][value]'); // Login as the first user. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Check that forum renders properly. $this->drupalGet("forum/{$this->forum['tid']}"); $this->assertResponse(200); @@ -475,13 +495,13 @@ function testForumWithNewPost() { * * @param array $forum * A forum array. - * @param boolean $container + * @param bool $container * TRUE if $forum is a container; FALSE otherwise. * * @return object * The created topic node. */ - function createForumTopic($forum, $container = FALSE) { + protected function createForumTopic($forum, $container = FALSE) { // Generate a random subject/body. $title = $this->randomMachineName(20); $body = $this->randomMachineName(200); @@ -506,7 +526,8 @@ function createForumTopic($forum, $container = FALSE) { $this->assertNoRaw(t('The item %title is a forum container, not a forum.', array('%title' => $forum['name'])), 'No error message was shown'); } - // Retrieve node object, ensure that the topic was created and in the proper forum. + // Retrieve node object, ensure that the topic was created + // and in the proper forum. $node = $this->drupalGetNodeByTitle($title); $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title))); $this->assertEqual($node->taxonomy_forums->target_id, $tid, 'Saved forum topic was in the expected forum'); @@ -524,9 +545,9 @@ function createForumTopic($forum, $container = FALSE) { * * @param \Drupal\Core\Entity\EntityInterface $node * The node being checked. - * @param $admin + * @param bool $admin * Boolean to indicate whether the user can 'access administration pages'. - * @param $response + * @param string $response * The exptected HTTP response code. */ private function verifyForums(EntityInterface $node, $admin, $response = 200) { @@ -545,7 +566,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { // View forum page. $this->verifyForumView($this->forum, $this->forumContainer); // View root forum page. - $this->verifyForumView($this->root_forum); + $this->verifyForumView($this->rootForum); // View forum node. $this->drupalGet('node/' . $node->id()); @@ -576,7 +597,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { $edit['title[0][value]'] = 'node/' . $node->id(); $edit['body[0][value]'] = $this->randomMachineName(256); // Assume the topic is initially associated with $forum. - $edit['taxonomy_forums'] = $this->root_forum['tid']; + $edit['taxonomy_forums'] = $this->rootForum['tid']; $edit['shadow'] = TRUE; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title[0][value]'])), 'Forum node was edited'); @@ -586,7 +607,7 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { ':nid' => $node->id(), ':vid' => $node->getRevisionId(), ))->fetchField(); - $this->assertTrue($forum_tid == $this->root_forum['tid'], 'The forum topic is linked to a different forum'); + $this->assertTrue($forum_tid == $this->rootForum['tid'], 'The forum topic is linked to a different forum'); // Delete forum node. $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete')); @@ -598,9 +619,9 @@ private function verifyForums(EntityInterface $node, $admin, $response = 200) { /** * Verifies the display of a forum page. * - * @param $forum + * @param array $forum * A row from the taxonomy_term_data table in an array. - * @param $parent + * @param array $parent * (optional) An array representing the forum's parent. */ private function verifyForumView($forum, $parent = NULL) { diff --git a/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php b/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php index de169f6..eb13410 100644 --- a/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php +++ b/core/modules/forum/src/Tests/Views/ForumIntegrationTest.php @@ -32,6 +32,9 @@ class ForumIntegrationTest extends ViewTestBase { */ public static $testViews = array('test_forum_index'); + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); @@ -53,7 +56,11 @@ public function testForumIntegration() { // Create some nodes which are part of this forum with some comments. $nodes = array(); for ($i = 0; $i < 3; $i++) { - $node = $this->drupalCreateNode(array('type' => 'forum', 'taxonomy_forums' => array($term->id()), 'sticky' => $i == 0 ? NODE_STICKY : NODE_NOT_STICKY)); + $node = $this->drupalCreateNode(array( + 'type' => 'forum', + 'taxonomy_forums' => array($term->id()), + 'sticky' => $i == 0 ? NODE_STICKY : NODE_NOT_STICKY, + )); $nodes[] = $node; } @@ -63,7 +70,13 @@ public function testForumIntegration() { $comments = array(); foreach ($nodes as $index => $node) { for ($i = 0; $i <= $index; $i++) { - $comment = $comment_storage->create(array('entity_type' => 'node', 'entity_id' => $node->id(), 'field_name' => 'comment_forum')); + $comment = $comment_storage->create( + array( + 'entity_type' => 'node', + 'entity_id' => $node->id(), + 'field_name' => 'comment_forum', + ) + ); $comment->save(); $comments[$comment->get('entity_id')->target_id][$comment->id()] = $comment; } @@ -76,17 +89,17 @@ public function testForumIntegration() { $expected_result[] = array( 'nid' => $nodes[0]->id(), 'sticky' => NODE_STICKY, - 'comment_count' => 1. + 'comment_count' => 1, ); $expected_result[] = array( 'nid' => $nodes[1]->id(), 'sticky' => NODE_NOT_STICKY, - 'comment_count' => 2. + 'comment_count' => 2, ); $expected_result[] = array( 'nid' => $nodes[2]->id(), 'sticky' => NODE_NOT_STICKY, - 'comment_count' => 3. + 'comment_count' => 3, ); $column_map = array( 'nid' => 'nid',