/**
  * Test function getPostsAuthorHasRepliedTo
  */
 public function testGetPostsAuthorHasRepliedTo()
 {
     $dao = new PostMySQLDAO();
     $posts_replied_to = $dao->getPostsAuthorHasRepliedTo(18, 10, 'twitter');
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user2");
     $this->assertEqual($posts_replied_to[0]["question"], "@shutterbug Nice shot!");
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "shutterbug");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user2 Thanks!");
     $posts_replied_to = $dao->getPostsAuthorHasRepliedTo(13, 10, 'twitter');
     $this->assertEqual(sizeof($posts_replied_to), 1);
     $this->assertEqual($posts_replied_to[0]["question_post_id"], 139);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user1");
     $this->assertEqual($posts_replied_to[0]["question"], "@ev When will Twitter have a business model?");
     $this->assertEqual($posts_replied_to[0]['answer_post_id'], 140);
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "ev");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user1 Soon...");
 }
 /**
  * Test function getPostsAuthorHasRepliedTo
  */
 public function testGetPostsAuthorHasRepliedTo()
 {
     //Public exchanges only
     $dao = new PostMySQLDAO();
     $posts_replied_to = $dao->getPostsAuthorHasRepliedTo(18, 10, 'twitter', 1, true);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user2");
     $this->assertEqual($posts_replied_to[0]["question"], "@shutterbug Nice shot!");
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "shutterbug");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user2 Thanks!");
     //set up a private exchange
     $builders[] = FixtureBuilder::build('posts', array('post_id' => 1000, 'author_user_id' => 20, 'author_username' => 'user1', 'author_fullname' => 'User 1', 'network' => 'twitter', 'post_text' => '@ev Privately, when will Twitter have a business model?', 'source' => 'web', 'pub_date' => '2010-03-01 00:00:00', 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'in_reply_to_post_id' => null, 'in_reply_to_user_id' => 13, 'is_protected' => 1));
     $builders[] = FixtureBuilder::build('posts', array('post_id' => 1001, 'author_user_id' => 13, 'author_username' => 'ev', 'author_fullname' => 'Ev Williams', 'network' => 'twitter', 'post_text' => '@user1 Privately? Soon...', 'source' => 'web', 'pub_date' => '2010-03-01 01:00:00', 'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'is_protected' => 1, 'reply_count_cache' => 0, 'retweet_count_cache' => 0, 'in_reply_to_user_id' => 20, 'in_reply_to_post_id' => 1000));
     $posts_replied_to = $dao->getPostsAuthorHasRepliedTo(13, 10, 'twitter', 1, true);
     $this->assertEqual(sizeof($posts_replied_to), 1);
     $this->assertEqual($posts_replied_to[0]["question_post_id"], 139);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user1");
     $this->assertEqual($posts_replied_to[0]["question"], "@ev When will Twitter have a business model?");
     $this->assertFalse($posts_replied_to[0]["question_is_protected"]);
     $this->assertEqual($posts_replied_to[0]['answer_post_id'], 140);
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "ev");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user1 Soon...");
     $this->assertFalse($posts_replied_to[0]["answer_is_protected"]);
     $posts_replied_to = $dao->getPostsAuthorHasRepliedTo(13, 10, 'twitter', 1, false);
     $this->assertEqual(sizeof($posts_replied_to), 2);
     $this->debug(Utils::varDumpToString($posts_replied_to));
     $this->assertEqual($posts_replied_to[0]["question_post_id"], 1000);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user1");
     $this->assertEqual($posts_replied_to[0]["question"], "@ev Privately, when will Twitter have a business model?");
     $this->assertTrue($posts_replied_to[0]["question_is_protected"]);
     $this->assertEqual($posts_replied_to[0]['answer_post_id'], 1001);
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "ev");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user1 Privately? Soon...");
     $this->assertTrue($posts_replied_to[0]["answer_is_protected"]);
     $this->assertEqual($posts_replied_to[1]["question_post_id"], 139);
     $this->assertEqual($posts_replied_to[1]["questioner_username"], "user1");
     $this->assertEqual($posts_replied_to[1]["question"], "@ev When will Twitter have a business model?");
     $this->assertEqual($posts_replied_to[1]['answer_post_id'], 140);
     $this->assertEqual($posts_replied_to[1]["answerer_username"], "ev");
     $this->assertEqual($posts_replied_to[1]["answer"], "@user1 Soon...");
 }
Example #3
0
 /**
  * Test getExchangesBetweenUsers
  */
 function testGetExchangesBetweenUsers()
 {
     $dao = new PostMySQLDAO();
     $posts_replied_to = $dao->getExchangesBetweenUsers(18, 21);
     $this->assertEqual(sizeof($posts_replied_to), 2);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "shutterbug");
     $this->assertEqual($posts_replied_to[0]["question"], "This is image post 1");
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "user2");
     $this->assertEqual($posts_replied_to[0]["answer"], "@shutterbug Nice shot!");
     $this->assertEqual($posts_replied_to[1]["questioner_username"], "user2");
     $this->assertEqual($posts_replied_to[1]["question"], "@shutterbug Nice shot!");
     $this->assertEqual($posts_replied_to[1]["answerer_username"], "shutterbug");
     $this->assertEqual($posts_replied_to[1]["answer"], "@user2 Thanks!");
     $posts_replied_to = $dao->getPostsAuthorHasRepliedTo(13, 20);
     $this->assertEqual(sizeof($posts_replied_to), 1);
     $this->assertEqual($posts_replied_to[0]["questioner_username"], "user1");
     $this->assertEqual($posts_replied_to[0]["question"], "@ev When will Twitter have a business model?");
     $this->assertEqual($posts_replied_to[0]["answerer_username"], "ev");
     $this->assertEqual($posts_replied_to[0]["answer"], "@user1 Soon....");
 }