コード例 #1
0
 /**
  * create dependent objects before running each test
  **/
 public final function setUp()
 {
     // run the default setUp() method first
     parent::setUp();
     // create and insert a Profile to own the test Tweet
     $this->profile = new Profile(null, "@phpunit", "*****@*****.**", "+12125551212");
     $this->profile->insert($this->getPDO());
     // create the test Tweet
     $this->tweet = new Tweet(null, $this->profile->getProfileId(), "PHPUnit favorite test passing");
     $this->tweet->insert($this->getPDO());
     // calculate the date (just use the time the unit test was setup...)
     $this->VALID_FAVORITEDATE = new DateTime();
 }
コード例 #2
0
ファイル: tweet-test.php プロジェクト: jfindley2/data-design
 /**
  * test grabbing all Tweets
  **/
 public function testGetAllValidTweets()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("tweet");
     // create a new Tweet and insert to into mySQL
     $tweet = new Tweet(null, $this->profile->getProfileId(), $this->VALID_TWEETCONTENT, $this->VALID_TWEETDATE);
     $tweet->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $results = Tweet::getAllTweets($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("tweet"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Tweet", $results);
     // grab the result from the array and validate it
     $pdoTweet = $results[0];
     $this->assertEquals($pdoTweet->getProfileId(), $this->profile->getProfileId());
     $this->assertEquals($pdoTweet->getTweetContent(), $this->VALID_TWEETCONTENT);
     $this->assertEquals($pdoTweet->getTweetDate(), $this->VALID_TWEETDATE);
 }
コード例 #3
0
ファイル: shakedown.php プロジェクト: Domkratos/instagram
<?php

require_once "/etc/apache2/capstone-mysql/encrypted-config.php";
$pdo = connectToEncryptedMySQL("/etc/apache2/data-design/dmartinez337.ini");
$tweet = new Tweet(null, 1, "this is from PHP");
$tweet->insert($pdo);
$tweet->setTweetContent("now I changed the message");
$tweet->update($pdo);
$tweet->delete($pdo);
コード例 #4
0
ファイル: tweet-cron.php プロジェクト: jschilli/Shine
<?php

require_once 'includes/master.inc.php';
$db = Database::getDatabase();
$tweet_apps = $db->getRows('SELECT id, tweet_terms FROM applications');
foreach ($tweet_apps as $tweet_app) {
    $terms = explode(',', $tweet_app['tweet_terms']);
    foreach ($terms as $term) {
        $term = trim($term);
        if (strlen($term) > 0) {
            $json = geturl("http://search.twitter.com/search.json?q=" . urlencode($term));
            $data = json_decode($json);
            if (!is_object($data)) {
                continue;
            }
            foreach ($data->results as $result) {
                $t = new Tweet();
                $t->tweet_id = $result->id;
                $t->username = $result->from_user;
                $t->app_id = $tweet_app['id'];
                $t->dt = dater($result->created_at);
                $t->body = $result->text;
                $t->profile_img = $result->profile_image_url;
                $t->new = 1;
                $t->replied_to = 0;
                $t->insert();
            }
        }
    }
}
コード例 #5
0
<?php

require 'connection.php';
require 'class_tweet.php';
set_time_limit(0);
$tweet = new Tweet();
$infomax = mysql_query("SELECT HashTag,MaxID FROM infomax WHERE Active='1'");
while ($info = mysql_fetch_array($infomax)) {
    $result_json = $tweet->get_json($info['HashTag'], $info['MaxID']);
    $obj = json_decode($result_json, TRUE);
    $maxid = mysql_real_escape_string($obj["max_id_str"]);
    $hash = mysql_real_escape_string($info['HashTag']);
    mysql_query("UPDATE infomax SET MaxID = {$maxid} WHERE HashTag='{$hash}'");
    if (isset($obj["results"])) {
        $tweet->insert($obj["results"], $hash);
    } else {
        header("HTTP/1.1 503 Service Unavailable");
    }
}
mysql_close($con);
unset($tweet);