Exemplo n.º 1
0
 public function testEnqueueStatusMockRedis()
 {
     //dont run redis test for php less than 5.3
     $version = explode('.', PHP_VERSION);
     if (!($version[0] >= 5 && $version[1] >= 3)) {
         //error_log("PHP version less than 5.3, Skipping Redis Tests...");
         return;
     } else {
         require_once THINKUP_ROOT_PATH . 'webapp/plugins/twitterrealtime/model/class.StreamMessageQueueRedis.php';
     }
     $stream_data = $this->setUpData(true);
     $twitter_data = $this->setUpTwitterData();
     $queue = new StreamMessageQueueRedis();
     $queue->redis = new MockRedis();
     StreamMessageQueueFactory::$queue = $queue;
     $consumer_user_stream = new ConsumerUserStream('username', 'password');
     $consumer_user_stream->setKey('*****@*****.**', 1);
     $procs_data = FixtureBuilder::build('stream_procs', array('process_id' => getmypid(), 'email' => '*****@*****.**', 'instance_id' => 1));
     $consumer_user_stream->enqueueStatus("string1");
     $consumer_user_stream->enqueueStatus("string2");
     $this->assertIdentical(array('string1', 'string2'), MockRedis::$queue);
     StreamMessageQueueFactory::$queue = null;
     MockRedis::$queue = null;
     // stream proc data set
     $sql = "select process_id, email, instance_id, unix_timestamp(last_report) as last_report from " . $this->table_prefix . "stream_procs";
     $stmt = PluginOptionMysqlDAO::$PDO->query($sql);
     $data = $stmt->fetchAll();
     $process_id = getmypid();
     $this->assertIdentical($data[0]['process_id'], $process_id . '');
     $recent_time = time() - 50;
     $this->assertTrue($data[0]['last_report'] > $recent_time);
 }
 public function testProcessStatus()
 {
     //dont run redis test for php less than 5.3
     $version = explode('.', PHP_VERSION);
     if (!($version[0] >= 5 && $version[1] >= 3)) {
         //error_log("PHP version less than 5.3, Skipping Redis Tests...");
         return;
     }
     MockRedis::$queue = null;
     $queue = new StreamMessageQueueRedis();
     $queue->redis = new MockRedis();
     // no data in the queue
     $this->assertNull($queue->processStreamData());
     // two items on the queue
     MockRedis::$queue = array('{json:1}', '{json:2}');
     $data = $queue->processStreamData();
     $this->assertNotNull($data);
     $this->assertEqual(count(MockRedis::$queue), 1, 'should be one item in the queue');
     $this->assertEqual($data, '{json:1}');
     $data = $queue->processStreamData();
     $this->assertNotNull($data);
     $this->assertEqual(count(MockRedis::$queue), 0, 'should be no items in the queue');
     $this->assertEqual($data, '{json:2}');
 }
Exemplo n.º 3
0
 public function __construct()
 {
     self::$queue = array();
 }