コード例 #1
0
 public function testAFacebookBatchRequestEntityCanBeUsedToSendABatchRequestToGraph()
 {
     $fbRequests = [new FacebookRequest($this->fbApp, 'token', 'GET', '/foo'), new FacebookRequest($this->fbApp, 'token', 'POST', '/bar')];
     $fbBatchRequest = new FacebookBatchRequest($this->fbApp, $fbRequests);
     $fbBatchClient = new FacebookClient(new MyFooBatchClientHandler());
     $response = $fbBatchClient->sendBatchRequest($fbBatchRequest);
     $this->assertInstanceOf('Facebook\\FacebookBatchResponse', $response);
     $this->assertEquals('GET', $response[0]->getRequest()->getMethod());
     $this->assertEquals('POST', $response[1]->getRequest()->getMethod());
 }
コード例 #2
0
 public function testAFacebookBatchRequestEntityCanBeUsedToSendABatchRequestToGraph()
 {
     $facebookApp = new FacebookApp('123', 'foo_secret');
     $facebookBatchRequest = m::mock('Facebook\\Entities\\FacebookBatchRequest');
     $facebookBatchRequest->shouldReceive('prepareRequestsForBatch')->once()->andReturn(null);
     $facebookBatchRequest->shouldReceive('getUrl')->once()->andReturn('');
     $facebookBatchRequest->shouldReceive('getMethod')->once()->andReturn('POST');
     $facebookBatchRequest->shouldReceive('getPostParams')->once()->andReturn([]);
     $facebookBatchRequest->shouldReceive('getHeaders')->once()->andReturn(['request_header' => 'foo']);
     $facebookBatchRequest->shouldReceive('getAccessToken')->once()->andReturn('foo_token');
     $facebookBatchRequest->shouldReceive('getApp')->once()->andReturn($facebookApp);
     $this->httpClientMock->shouldReceive('send')->with(FacebookClient::BASE_GRAPH_URL, 'POST', [], ['request_header' => 'foo'])->once()->andReturn('[]');
     $this->httpClientMock->shouldReceive('getResponseHttpStatusCode')->once()->andReturn(200);
     $this->httpClientMock->shouldReceive('getResponseHeaders')->once()->andReturn(['response_header' => 'bar']);
     $client = new FacebookClient($this->httpClientMock);
     $response = $client->sendBatchRequest($facebookBatchRequest);
     $this->assertInstanceOf('Facebook\\Entities\\FacebookBatchResponse', $response);
 }