Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ticket/500] Show correct number of replies in news and announcements #501

Merged
merged 1 commit into from
Mar 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']);
}
}