/**
  * Test getAllQuestionPostosInRange
  */
 public function testgetAllQuestionPostsInRange()
 {
     $builders = array();
     //Add a question
     $post_builder = FixtureBuilder::build('posts', array('author_user_id' => '13', 'author_username' => 'ev', 'post_text' => 'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 ' . 'What should I buy?', 'network' => 'twitter', 'in_reply_to_post_id' => 0, 'pub_date' => '2006-02-01 00:05:00'));
     array_push($builders, $post_builder);
     $post_key = $post_builder->columns['last_insert_id'];
     $builders[] = FixtureBuilder::build('links', array('post_key' => $post_key, 'url' => 'http://bit.ly/blah'));
     $builders[] = FixtureBuilder::build('links', array('post_key' => $post_key, 'url' => 'http://bit.ly/blah2'));
     $dao = new PostMySQLDAO();
     $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:04:00', $until = '2006-02-02 00:10:00');
     $this->debug('Questions: ' . $questions);
     $this->assertEqual(sizeof($questions), 1);
     $this->assertEqual($questions[0]->post_text, 'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 What should I buy?');
     $this->assertEqual(sizeof($questions[0]->links), 2);
     $this->assertEqual($questions[0]->links[0]->url, 'http://bit.ly/blah');
     $this->assertEqual($questions[0]->links[1]->url, 'http://bit.ly/blah2');
     //Add another question
     $builder[] = FixtureBuilder::build('posts', array('author_user_id' => 13, 'author_username' => 'ev', 'post_text' => 'Best sushi in NY? downtown', 'network' => 'twitter', 'in_reply_to_post_id' => 0, 'pub_date' => '2006-02-01 00:06:00'));
     $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:04:00', $until = '2006-02-01 00:10:00');
     $this->assertEqual(sizeof($questions), 2);
     $this->assertEqual($questions[0]->post_text, 'Best sushi in NY? downtown');
     $this->assertEqual($questions[1]->post_text, 'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 What should I buy?');
     //Messages with a question mark in between two characters (e.g. URLs) aren't necessarily questions
     $builder[] = FixtureBuilder::build('posts', array('author_user_id' => 13, 'author_username' => 'ev', 'post_text' => 'Love this video: http://www.youtube.com/watch?v=PQu-zrE-k5s', 'network' => 'twitter', 'in_reply_to_post_id' => 0, 'pub_date' => '2006-02-01 00:07:00'));
     $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:04:00', $until = '2006-02-01 00:10:00');
     $this->assertEqual(sizeof($questions), 2);
     // test ascending order
     $posts = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:01:00', $until = '2006-02-01 00:10:00', $page = 1, $order_by = 'pub_date', $direction = 'ASC');
     $this->assertEqual(sizeof($posts), 2);
     foreach ($posts as $post) {
         $this->assertTrue(strtotime($post->pub_date) >= $date);
         $date = strtotime($post->pub_date);
     }
     // test range with no posts
     $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:10:00', $until = '2006-02-01 00:15:00');
     $this->assertEqual(sizeof($questions), 0);
     // test from greater than until
     $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:10:00', $until = '2006-01-01 00:15:00');
     $this->assertEqual(sizeof($questions), 0);
 }