Skip to content

Commit

Permalink
[ticket/500] Show correct number of replies in news and announcements
Browse files Browse the repository at this point in the history
B3P-500
  • Loading branch information
marc1706 committed Mar 9, 2015
1 parent c3e1128 commit 131b7a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions portal/fetch_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ public function fill_posts_array($row, $text_length, $i, &$have_icons, &$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'],
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/functions/fetch_news_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,12 @@ public function test_no_allowed_forums()
$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']);
}
}
9 changes: 9 additions & 0 deletions tests/unit/portal/fetch_posts_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,13 @@ public function test_no_allowed_forums()
$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']);
}
}

0 comments on commit 131b7a6

Please sign in to comment.