/** * Test getRepliesToPostIterator */ public function testGetRepliesToPostIterator() { $dao = new PostMySQLDAO(); // Default Sorting $posts_it = $dao->getRepliesToPostIterator(41, 'twitter'); $post1 = null; $post2 = null; $post3 = null; $cnt = 0; foreach ($posts_it as $post) { $cnt++; if ($cnt == 1) { $post1 = $post; } if ($cnt == 2) { $post2 = $post; } if ($cnt == 3) { $post3 = $post; } } $this->assertEqual($cnt, 3); $this->assertEqual($post1->post_text, '@shutterbug Nice shot!', "post reply"); $this->assertEqual($post1->location, 'New Delhi, Delhi, India'); $this->assertEqual($post2->location, 'Chennai, Tamil Nadu, India'); $this->assertEqual($post3->post_text, '@shutterbug This is a link post reply http://example.com/', "post reply"); $this->assertEqual($post3->post_id, 133, "post ID"); // test paging $posts_it = $dao->getRepliesToPostIterator(41, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 1); $posts_it->valid(); $this->assertEqual($posts_it->current()->post_text, '@shutterbug Nice shot!'); $posts_it = $dao->getRepliesToPostIterator(41, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 2); $posts_it->valid(); $this->assertEqual($posts_it->current()->location, 'Chennai, Tamil Nadu, India'); $posts_it = $dao->getRepliesToPostIterator(41, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 3); $posts_it->valid(); $this->assertEqual($posts_it->current()->post_text, '@shutterbug This is a link post reply http://example.com/'); // test count $posts = array(); $posts_it = $dao->getRepliesToPostIterator(41, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 1, $page = 1); foreach ($posts_it as $post) { $posts[] = $post; } $this->assertEqual(sizeof($posts), 1); $posts = array(); $posts_it = $dao->getRepliesToPostIterator(41, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 2, $page = 1); foreach ($posts_it as $post) { $posts[] = $post; } $this->assertEqual(sizeof($posts), 2); $posts = array(); $posts_it = $dao->getRepliesToPostIterator(41, 'twitter', $order_by = 'default', $unit = 'km', $is_public = false, $count = 3, $page = 1); foreach ($posts_it as $post) { $posts[] = $post; } $this->assertEqual(sizeof($posts), 3); }
/** * Test getRepliesToPostIterator */ public function testGetRepliesToPostIterator() { $dao = new PostMySQLDAO(); // Default Sorting $posts_it = $dao->getRepliesToPostIterator(41, 'twitter'); $post1 = null; $post2 = null; $post3 = null; $cnt = 0; foreach ($posts_it as $post) { $cnt++; if ($cnt == 1) { $post1 = $post; } if ($cnt == 2) { $post2 = $post; } if ($cnt == 3) { $post3 = $post; } } $this->assertEqual($cnt, 3); $this->assertEqual($post1->post_text, '@shutterbug Nice shot!', "post reply"); $this->assertEqual($post1->location, 'New Delhi, Delhi, India'); $this->assertEqual($post2->location, 'Chennai, Tamil Nadu, India'); $this->assertEqual($post3->post_text, '@shutterbug This is a link post reply http://example.com/', "post reply"); $this->assertEqual($post3->post_id, 133, "post ID"); }