Example #1
1
 public function setUp()
 {
     $this->faker = Factory::create();
     $this->id = TwitterMessageId::create($this->faker->uuid);
     $this->lang = $this->faker->countryISOAlpha3;
     $this->userName = $this->faker->userName;
     $this->hashtagText = $this->faker->word;
     $this->text = $this->faker->text();
     $this->complexText = '@' . $this->userName . ' ' . $this->text . ' #' . $this->hashtagText;
     $this->date = new \DateTimeImmutable();
     $this->coordinates = \Mockery::mock(TwitterCoordinates::class);
     $this->place = \Mockery::mock(TwitterPlace::class);
     $this->inReplyToStatusId = $this->faker->randomNumber();
     $this->inReplyToUserId = $this->faker->randomNumber();
     $this->inReplyToScreenName = $this->faker->userName;
     $this->retweeted = $this->faker->boolean();
     $this->retweetCount = $this->faker->randomNumber();
     $this->favorited = $this->faker->boolean();
     $this->favoriteCount = $this->faker->randomNumber();
     $this->truncated = $this->faker->boolean();
     $this->source = null;
     $this->retweetedStatus = \Mockery::mock(Tweet::class);
     $this->hashtag = \Mockery::mock(TwitterHashtag::class);
     $this->userMention = \Mockery::mock(TwitterUserMention::class);
     $this->sender = \Mockery::mock(TwitterUser::class);
     $this->recipient = \Mockery::mock(TwitterUser::class);
     $this->entities = \Mockery::mock(TwitterEntities::class);
 }
Example #2
0
 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return \Twitter\Object\Tweet
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $createdAt = new \DateTimeImmutable($obj->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return Tweet::create(TwitterMessageId::create($obj->id), $this->userSerializer->unserialize($obj->user), $obj->text, $obj->lang, $createdAt, $obj->entities ? $this->twitterEntitiesSerializer->unserialize($obj->entities) : TwitterEntities::create(), $obj->coordinates ? $this->coordinatesSerializer->unserialize($obj->coordinates) : null, $obj->place ? $this->placeSerializer->unserialize($obj->place) : null, $obj->in_reply_to_status_id, $obj->in_reply_to_user_id, $obj->in_reply_to_screen_name, $obj->retweeted, $obj->retweet_count, $obj->favorited, $obj->favorite_count, $obj->truncated, $obj->source, isset($obj->retweeted_status) ? $this->unserialize($obj->retweeted_status) : null);
 }
 /**
  * @param  \stdClass $directMessage
  * @param  array     $context
  * @return TwitterDirectMessage
  */
 public function unserialize($directMessage, array $context = [])
 {
     Assertion::true($this->canUnserialize($directMessage), 'object is not unserializable');
     $dm = $directMessage->direct_message;
     $createdAt = new \DateTimeImmutable($dm->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return TwitterDirectMessage::create(TwitterMessageId::create($dm->id), $this->userSerializer->unserialize($dm->sender), $this->userSerializer->unserialize($dm->recipient), $dm->text, $createdAt, $this->twitterEntitiesSerializer->canUnserialize($dm->entities) ? $this->twitterEntitiesSerializer->unserialize($dm->entities) : TwitterEntities::create());
 }
Example #4
0
 public function setUp()
 {
     $this->faker = Factory::create();
     $this->id = TwitterMessageId::create($this->faker->uuid);
     $this->userName = $this->faker->userName;
     $this->hashtagText = $this->faker->word;
     $this->text = $this->faker->text();
     $this->complexText = '@' . $this->userName . ' ' . $this->text . ' #' . $this->hashtagText;
     $this->date = new \DateTimeImmutable();
     $this->hashtag = \Mockery::mock(TwitterHashtag::class);
     $this->userMention = \Mockery::mock(TwitterUserMention::class);
     $this->sender = \Mockery::mock(TwitterUser::class);
     $this->recipient = \Mockery::mock(TwitterUser::class);
     $this->entities = \Mockery::mock(TwitterEntities::class);
 }
 public function setUp()
 {
     $faker = Factory::create();
     $this->id = $faker->randomNumber();
     $this->text = $faker->text();
     $this->date = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
     $this->serializedSender = new \stdClass();
     $this->serializedRecipient = new \stdClass();
     $this->serializedEntities = new \stdClass();
     $this->sender = \Mockery::mock(TwitterUser::class);
     $this->recipient = \Mockery::mock(TwitterUser::class);
     $this->twitterEntities = \Mockery::mock(TwitterEntities::class);
     $this->serializedDirectMessage = $this->getSerializedDirectMessage();
     $this->directMessage = TwitterDirectMessage::create(TwitterMessageId::create($this->id), $this->sender, $this->recipient, $this->text, $this->date, $this->twitterEntities);
     $this->userSerializer = \Mockery::mock(TwitterUserSerializer::class);
     $this->entitiesSerializer = \Mockery::mock(TwitterEntitiesSerializer::class);
     $this->serviceUnderTest = new TwitterDirectMessageSerializer($this->userSerializer, $this->entitiesSerializer);
 }