Example #1
0
 /**
  * Test update author_username on a series of posts
  */
 public function testUpdateAuthorUsernameByAuthorUserId()
 {
     $dao = new PostMySQLDAO();
     $post = $dao->getPost(10, 'twitter');
     $authorid = $post->author_user_id;
     // bad id
     $update_cnt = $dao->updateAuthorUsername(-99, 'twitter', 'newname');
     $this->assertEqual($update_cnt, 0);
     // bad network
     $update_cnt = $dao->updateAuthorUsername($authorid, 'no-net', 'newname');
     $this->assertEqual($update_cnt, 0);
     // good id
     $update_cnt = $dao->updateAuthorUsername($authorid, 'twitter', 'newname');
     $stmt = PostMySQLDAO::$PDO->query("select * from " . $this->table_prefix . "posts where author_user_id = {$authorid} and network = 'twitter'");
     $data_returned = false;
     $cnt = 0;
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $this->assertEqual($row['author_username'], 'newname');
         $data_returned = true;
         $cnt++;
     }
     $stmt->closeCursor();
     $this->assertTrue($data_returned);
     $this->assertEqual($update_cnt, $cnt);
 }