/** * Test GuzzleClient is called correctly. * * Short circuit the output with an exception * * @expectedException JimLind\Pie7o\Pie7oException * @expectedExceptionMessage Could Not Upload Media: `` */ public function testGuzzleClientSendCalledWithRequestAndOptions() { $auth = uniqid(); $contents = uniqid(); $this->authorizationBuilder->method('build')->willReturn($auth); $stream = $this->getMock('Psr\\Http\\Message\\StreamInterface'); $stream->method('getContents')->willReturn($contents); $tweet = $this->getMock('JimLind\\Pie7o\\Tweet'); $tweet->method('getMedia')->willReturn($stream); $request = (new Request('POST', 'https://upload.twitter.com/1.1/media/upload.json'))->withHeader('Authorization', $auth); $options = ['multipart' => [['name' => 'media', 'contents' => $contents]]]; $this->guzzleClient->method('send')->with($request, $options)->will($this->throwException(new Exception())); $this->fixture->upload($tweet); }
/** * Test GuzzleClient is called correctly including Media Id. * * Short circuit the output with an exception * * @expectedException JimLind\Pie7o\Pie7oException * @expectedExceptionMessage Could Not Update Status: `` */ public function testGuzzleClientSendCalledWithRequestAndOptionsIncludingMediaId() { $auth = uniqid(); $contents = uniqid(); $mediaId = uniqid(); $this->authorizationBuilder->method('build')->willReturn($auth); $stream = $this->getMock('Psr\\Http\\Message\\StreamInterface'); $stream->method('getContents')->willReturn($contents); $tweet = $this->getMock('JimLind\\Pie7o\\Tweet'); $tweet->method('getMessage')->willReturn($stream); $tweet->method('getMediaId')->willReturn($mediaId); $request = (new Request('POST', 'https://api.twitter.com/1.1/statuses/update.json'))->withHeader('Authorization', $auth); $options = ['form_params' => ['status' => $contents, 'media_ids' => $mediaId]]; $this->guzzleClient->method('send')->with($request, $options)->will($this->throwException(new Exception())); $this->fixture->update($tweet); }
/** * Test sendTwitterRequest called with default post data. */ public function testSendTwitterRequestWithDefaultPostData() { $this->authorizationBuilder->expects($this->once())->method('build')->with('POST', 'https://', []); $tweet = $this->getMock('JimLind\\Pie7o\\Tweet'); $this->callFixtureWithTweet($tweet); }