/** * 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()); }
/** * Parse Guzzle response and add media data to return Tweet. * * @param Response $response * @param Tweet $tweet * * @return Tweet */ protected function handleResponse(Response $response, Tweet $tweet) { $bodyString = $response->getBody(); $bodyJson = json_decode($bodyString); return $tweet->withMediaId($bodyJson->{'media_id'}); }