Esempio n. 1
0
 /**
  * Test giving a Tweet a media id allows you to get it.
  */
 public function testMediaIdSetGet()
 {
     $mediaId = rand();
     $mediaString = (string) $mediaId;
     $output = $this->fixture->withMediaId($mediaString);
     $this->assertSame($mediaId, $output->getMediaId());
     // Make sure other properties are not affected
     $this->assertNull($output->getMedia());
     $this->assertNull($output->getMessage());
     $this->assertSame(0, $this->fixture->getMediaId());
     $this->assertNull($this->fixture->getMessage());
     $this->assertNull($this->fixture->getMedia());
 }
Esempio n. 2
0
 /**
  * Tweet by optionally uploading media and updating status.
  *
  * @param Tweet $tweet
  */
 public function tweet(Tweet $tweet)
 {
     if ($tweet->getMedia() instanceof StreamInterface) {
         $tweet = $this->mediaUploader->upload($tweet);
     }
     $this->statusUpdater->update($tweet);
 }
Esempio n. 3
0
 /**
  * Create options for a multipart binary file upload.
  *
  * @param Tweet $tweet
  *
  * @return array
  */
 protected function getOptions(Tweet $tweet)
 {
     $mediaStream = $tweet->getMedia();
     $mediaStream->rewind();
     $file = ['name' => 'media', 'contents' => $mediaStream->getContents()];
     return ['multipart' => [$file]];
 }