/** * Test getMostRepliedToPosts */ public function testGetMostRepliedToPosts() { $dao = new PostMySQLDAO(); $posts = $dao->getMostRepliedToPosts(13, 'twitter', 10); $prev_count = $posts[0]->reply_count_cache; foreach ($posts as $post) { $this->assertTrue($post->reply_count_cache <= $prev_count, "previous count " . $prev_count . " should be less than or equal to this post's count of " . $post->reply_count_cache); $prev_count = $post->reply_count_cache; } // test paging $posts = $dao->getMostRepliedToPosts(13, 'twitter', $count = 1, $page = 1); $prev_count = $posts[0]->reply_count_cache; for ($i = 2; $i <= 10; $i++) { $posts = $dao->getMostRepliedToPosts(13, 'twitter', $count = 1, $page = $i); $this->assertTrue($posts[0]->reply_count_cache <= $prev_count, "previous count " . $prev_count . " should be less than or equal to this post's count of " . $posts[0]->reply_count_cache); $prev_count = $posts[0]->reply_count_cache; } // test count for ($i = 2; $i <= 10; $i++) { $posts = $dao->getMostRepliedToPosts(13, 'twitter', $count = $i, $page = 1); $this->assertTrue(count($posts) == $i); } }
/** * Test getMostRepliedToPosts */ public function testGetMostRepliedToPosts() { $dao = new PostMySQLDAO(); $posts = $dao->getMostRepliedToPosts(13, 'twitter', 10); $prev_count = $posts[0]->reply_count_cache; foreach ($posts as $post) { $this->assertTrue($post->reply_count_cache <= $prev_count, "previous count " . $prev_count . " should be less than or equal to this post's count of " . $post->reply_count_cache); $prev_count = $post->reply_count_cache; } }