Merge pull request #501 from marc1706/ticket/500

[ticket/500] Show correct number of replies in news and announcements
This commit is contained in:
Marc Alexander
2015-03-09 22:32:24 +01:00
3 changed files with 19 additions and 2 deletions

View File

@@ -321,8 +321,8 @@ class fetch_posts
'icon_id' => $row['icon_id'],
'topic_status' => $row['topic_status'],
'forum_id' => $row['forum_id'],
'topic_replies' => $row['topic_posts_approved'] + $row['topic_posts_unapproved'] + $row['topic_posts_softdeleted'],
'topic_replies_real' => $row['topic_posts_approved'],
'topic_replies' => $row['topic_posts_approved'] + $row['topic_posts_unapproved'] + $row['topic_posts_softdeleted'] - 1,
'topic_replies_real' => $row['topic_posts_approved'] - 1,
'topic_time' => $this->user->format_date($row['post_time']),
'topic_last_post_time' => $row['topic_last_post_time'],
'topic_title' => $row['topic_title'],

View File

@@ -264,4 +264,12 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
$fetch_posts = phpbb_fetch_posts(5, '2', true, 5, 150, time(), 'announcements');
$this->assertSame(array(), $fetch_posts);
}
public function test_number_replies()
{
$fetch_posts = phpbb_fetch_posts(5, '', false, 5, 150, time(), 'news');
// Topic has 2 posts which means there is only one reply
$this->assertEquals(1, $fetch_posts[0]['topic_replies']);
$this->assertEquals(1, $fetch_posts[0]['topic_replies_real']);
}
}

View File

@@ -266,4 +266,13 @@ class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\d
$fetch_posts = $this->fetch_posts->get_posts('2', true, 5, 150, time(), 'announcements');
$this->assertSame(array(), $fetch_posts);
}
public function test_number_replies()
{
$this->fetch_posts->set_module_id(5);
$fetch_posts = $this->fetch_posts->get_posts('', false, 5, 150, time(), 'news');
// Topic has 2 posts which means there is only one reply
$this->assertEquals(1, $fetch_posts[0]['topic_replies']);
$this->assertEquals(1, $fetch_posts[0]['topic_replies_real']);
}
}