Exemplo n.º 1
0
 public function testGetTweetsInJsonFile()
 {
     // test data
     $filename = dirname(__FILE__) . '/json/2012_10.js';
     $notJSONFilename = dirname(__FILE__) . '/json/not_json.js';
     $badFilename = dirname(__FILE__) . '/json/this_is_not_a_real_file.js';
     $importer = new Importer();
     // make sure the return value is correct
     $tweets = $importer->getTweetsInJsonFile($filename);
     $this->assertCount(6, $tweets);
     $this->assertEquals('AMWhalen\\ArchiveMyTweets\\Tweet', get_class($tweets[0]));
     $this->assertEquals(263364339371765760, $tweets[0]->id);
     $this->assertEquals(14061545, $tweets[0]->user_id);
     $this->assertEquals(263360591496896513, $tweets[0]->in_reply_to_status_id);
     // test non-existent file
     $this->assertFalse($importer->getTweetsInJsonFile($badFilename));
     // test non-json data
     $this->assertFalse($importer->getTweetsInJsonFile($notJSONFilename));
 }