@ -29,7 +29,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testBasicProfileInfo () {
list ( $url , $json ) = $this -> loadTweet ( '818912506496229376' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'aaronpk dev' , $data [ 'data' ][ 'author' ][ 'name' ]);
@ -43,7 +43,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testProfileWithNonExpandedURL () {
list ( $url , $json ) = $this -> loadTweet ( '791704641046052864' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'http://agiletortoise.com' , $data [ 'data' ][ 'author' ][ 'url' ]);
}
@ -51,9 +51,9 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testBasicTestStuff () {
list ( $url , $json ) = $this -> loadTweet ( '818913630569664512' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 200 , $data [ 'code' ]);
$this -> assertEquals ( null , $data [ 'code' ]); // no code is expected if we pass in the body
$this -> assertEquals ( 'https://twitter.com/pkdev/status/818913630569664512' , $data [ 'url' ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'A tweet with a URL https://indieweb.org/ #and #some #hashtags' , $data [ 'data' ][ 'content' ][ 'text' ]);
@ -67,14 +67,14 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testPositiveTimezone () {
list ( $url , $json ) = $this -> loadTweet ( '719914707566649344' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( " 2016-04-12T16:46:56+01:00 " , $data [ 'data' ][ 'published' ]);
}
public function testTweetWithEmoji () {
list ( $url , $json ) = $this -> loadTweet ( '818943244553699328' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Here 🎉 have an emoji' , $data [ 'data' ][ 'content' ][ 'text' ]);
@ -83,7 +83,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testHTMLEscaping () {
list ( $url , $json ) = $this -> loadTweet ( '818928092383166465' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Double escaping & & amp' , $data [ 'data' ][ 'content' ][ 'text' ]);
@ -92,7 +92,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testTweetWithPhoto () {
list ( $url , $json ) = $this -> loadTweet ( '818912506496229376' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Tweet with a photo and a location' , $data [ 'data' ][ 'content' ][ 'text' ]);
@ -102,7 +102,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testTweetWithTwoPhotos () {
list ( $url , $json ) = $this -> loadTweet ( '818935308813103104' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Two photos' , $data [ 'data' ][ 'content' ][ 'text' ]);
@ -113,7 +113,7 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testTweetWithVideo () {
list ( $url , $json ) = $this -> loadTweet ( '818913178260160512' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Tweet with a video' , $data [ 'data' ][ 'content' ][ 'text' ]);
@ -123,12 +123,12 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testTweetWithLocation () {
list ( $url , $json ) = $this -> loadTweet ( '818912506496229376' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Tweet with a photo and a location' , $data [ 'data' ][ 'content' ][ 'text' ]);
$this -> assertEquals ( 'https://api.twitter.com/1.1/geo/id/ac88a4f17a51c7fc.json' , $data [ 'data' ][ 'location' ]);
$location = $data [ 'refs' ][ 'https://api.twitter.com/1.1/geo/id/ac88a4f17a51c7fc.json' ];
$location = $data [ 'data' ][ ' refs' ][ 'https://api.twitter.com/1.1/geo/id/ac88a4f17a51c7fc.json' ];
$this -> assertEquals ( 'adr' , $location [ 'type' ]);
$this -> assertEquals ( 'Portland' , $location [ 'locality' ]);
$this -> assertEquals ( 'United States' , $location [ 'country-name' ]);
@ -138,38 +138,38 @@ class TwitterTest extends PHPUnit_Framework_TestCase {
public function testRetweet () {
list ( $url , $json ) = $this -> loadTweet ( '818913351623245824' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertArrayNotHasKey ( 'content' , $data [ 'data' ]);
$repostOf = 'https://twitter.com/aaronpk/status/817414679131660288' ;
$this -> assertEquals ( $repostOf , $data [ 'data' ][ 'repost-of' ]);
$tweet = $data [ 'refs' ][ $repostOf ];
$tweet = $data [ 'data' ][ ' refs' ][ $repostOf ];
$this -> assertEquals ( 'Yeah that\'s me http://xkcd.com/1782/' , $tweet [ 'content' ][ 'text' ]);
}
public function testRetweetWithPhoto () {
list ( $url , $json ) = $this -> loadTweet ( '820039442773798912' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertArrayNotHasKey ( 'content' , $data [ 'data' ]);
$this -> assertArrayNotHasKey ( 'photo' , $data [ 'data' ]);
$repostOf = 'https://twitter.com/phlaimeaux/status/819943954724556800' ;
$this -> assertEquals ( $repostOf , $data [ 'data' ][ 'repost-of' ]);
$tweet = $data [ 'refs' ][ $repostOf ];
$tweet = $data [ 'data' ][ ' refs' ][ $repostOf ];
$this -> assertEquals ( 'this headline is such a rollercoaster' , $tweet [ 'content' ][ 'text' ]);
}
public function testQuotedTweet () {
list ( $url , $json ) = $this -> loadTweet ( '818913488609251331' );
$data = $this -> parse ([ 'url' => $url , 'json ' => $json ]);
$data = $this -> parse ([ 'url' => $url , 'body ' => $json ]);
$this -> assertEquals ( 'entry' , $data [ 'data' ][ 'type' ]);
$this -> assertEquals ( 'Quoted tweet with a #hashtag https://twitter.com/aaronpk/status/817414679131660288' , $data [ 'data' ][ 'content' ][ 'text' ]);
$tweet = $data [ 'refs' ][ 'https://twitter.com/aaronpk/status/817414679131660288' ];
$tweet = $data [ 'data' ][ ' refs' ][ 'https://twitter.com/aaronpk/status/817414679131660288' ];
$this -> assertEquals ( 'Yeah that\'s me http://xkcd.com/1782/' , $tweet [ 'content' ][ 'text' ]);
}