/** * Test getRetweetsOfPost */ public function testGetRetweetsOfPost() { $dao = new PostMySQLDAO(); // Default Sorting $posts = $dao->getRetweetsOfPost(134, 'twitter'); $this->assertEqual(sizeof($posts), 3); $this->assertEqual($posts[0]->location, 'Chennai, Tamil Nadu, India'); $this->assertEqual($posts[1]->location, 'Dwarka, New Delhi, Delhi, India'); $this->assertEqual($posts[2]->location, 'Mumbai, Maharashtra, India'); $this->assertEqual($posts[0]->post_text, 'RT @quoter Be liberal in what you accept and conservative in what you send', "post reply"); $this->assertEqual($posts[0]->author->username, 'user1', "Post author"); // Sorting By Proximity $posts = $dao->getRetweetsOfPost(134, 'twitter', 'location'); $this->assertEqual(sizeof($posts), 3); $this->assertEqual($posts[0]->location, 'Dwarka, New Delhi, Delhi, India'); $this->assertEqual($posts[1]->location, 'Mumbai, Maharashtra, India'); $this->assertEqual($posts[1]->post_text, 'RT @quoter Be liberal in what you accept and conservative in what you send', "post reply"); $this->assertEqual($posts[2]->location, 'Chennai, Tamil Nadu, India'); $this->assertEqual($posts[2]->author->username, 'user1', "Post author"); }
/** * Test getRetweetsOfPost */ public function testGetRetweetsOfPost() { $dao = new PostMySQLDAO(); // Default Sorting $posts = $dao->getRetweetsOfPost(134, 'twitter'); $this->assertEqual(sizeof($posts), 3); $this->assertEqual($posts[0]->location, 'Chennai, Tamil Nadu, India'); $this->assertEqual($posts[1]->location, 'Dwarka, New Delhi, Delhi, India'); $this->assertEqual($posts[2]->location, 'Mumbai, Maharashtra, India'); $this->assertEqual($posts[0]->post_text, 'RT @quoter Be liberal in what you accept and conservative in what you send', "post reply"); $this->assertEqual($posts[0]->author->username, 'user1', "Post author"); // Sorting By Proximity $posts = $dao->getRetweetsOfPost(134, 'twitter', 'location'); $this->assertEqual(sizeof($posts), 3); $this->assertEqual($posts[0]->location, 'Dwarka, New Delhi, Delhi, India'); $this->assertEqual($posts[1]->location, 'Mumbai, Maharashtra, India'); $this->assertEqual($posts[1]->post_text, 'RT @quoter Be liberal in what you accept and conservative in what you send', "post reply"); $this->assertEqual($posts[2]->location, 'Chennai, Tamil Nadu, India'); $this->assertEqual($posts[2]->author->username, 'user1', "Post author"); // Sorting by Date $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'pub_date', $unit = 'km', $is_public = false, $count = 10, $page = 1); $pub_date = strtotime($posts[0]->pub_date); foreach ($posts as $post) { $this->assertTrue(strtotime($post->pub_date) <= $pub_date); $pub_date = strtotime($post->pub_date); } // test paging $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 1); $this->assertEqual(sizeof($posts), 1); $this->assertEqual($posts[0]->location, 'Chennai, Tamil Nadu, India'); $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 2); $this->assertEqual(sizeof($posts), 1); $this->assertEqual($posts[0]->location, 'Dwarka, New Delhi, Delhi, India'); $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 3); $this->assertEqual(sizeof($posts), 1); $this->assertEqual($posts[0]->location, 'Mumbai, Maharashtra, India'); // test count $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 1); $this->assertEqual(sizeof($posts), 1); $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 2, $page = 1); $this->assertEqual(sizeof($posts), 2); $posts = $dao->getRetweetsOfPost(134, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 3, $page = 1); $this->assertEqual(sizeof($posts), 3); }
/** * Test getRetweetsOfPost */ function testGetRetweetsOfPost() { $dao = new PostMySQLDAO(); $posts = $dao->getRetweetsOfPost(134); $this->assertEqual(sizeof($posts), 3); $this->assertEqual($posts[0]->post_text, 'RT @quoter Be liberal in what you accept and conservative in what you send', "post reply"); $this->assertEqual($posts[0]->author->username, 'user1', "Post author"); }