public function testExportRepliesToRetweetsOfServiceUser() { $post_dao = new PostMySQLDAO(); $posts_to_process = $post_dao->getAllPosts(13, 'twitter', 500, 1); $replies_rts_exported = $this->dao->exportRepliesRetweetsOfPosts($posts_to_process); //2 replies and 1 retweet $this->assertEqual($replies_rts_exported, 3); }
/** * Test getAllPosts */ public function testGetAllPosts() { $dao = new PostMySQLDAO(); //more than count $posts = $dao->getAllPosts(18, 'twitter', 10); $this->assertEqual(sizeof($posts), 10); //less than count $posts = $dao->getAllPosts(18, 'twitter', 50); $this->assertEqual(sizeof($posts), 41); //page 2 $posts = $dao->getAllPosts(18, 'twitter', 10, 2); $this->assertEqual(sizeof($posts), 10); //less than count, no replies --there is 1 reply, so 41-1=40 $posts = $dao->getAllPosts(18, 'twitter', 50, 1, false); $this->assertEqual(sizeof($posts), 40); //non-existent author $posts = $dao->getAllPosts(30, 'twitter', 10); $this->assertEqual(sizeof($posts), 0); // test order by $posts = $dao->getAllPosts(18, 'twitter', 10, $page = 1, $include_replies = true, $order_by = 'pub_date', $direction = 'DESC'); $this->assertEqual(sizeof($posts), 10); $this->assertEqual($posts[0]->post_id, 138); $this->assertEqual($posts[1]->post_id, 79); $this->assertEqual($posts[2]->post_id, 78); // test default order_by $posts = $dao->getAllPosts(18, 'twitter', 10, $page = 1, $include_replies = true, $order_by = "';-- SELECT", $direction = 'DESC'); $this->assertEqual(sizeof($posts), 10); $this->assertEqual($posts[0]->post_id, 138); $this->assertEqual($posts[1]->post_id, 79); $this->assertEqual($posts[2]->post_id, 78); }
/** * Test getAllPosts */ public function testGetAllPosts() { $dao = new PostMySQLDAO(); //more than count $posts = $dao->getAllPosts(18, 'twitter', 10); $this->assertEqual(sizeof($posts), 10); //less than count $posts = $dao->getAllPosts(18, 'twitter', 50); $this->assertEqual(sizeof($posts), 41); //page 2 $posts = $dao->getAllPosts(18, 'twitter', 10, 2); $this->assertEqual(sizeof($posts), 10); //less than count, no replies --there is 1 reply, so 41-1=40 $posts = $dao->getAllPosts(18, 'twitter', 50, 1, false); $this->assertEqual(sizeof($posts), 40); //non-existent author $posts = $dao->getAllPosts(30, 'twitter', 10); $this->assertEqual(sizeof($posts), 0); }