/** @dataProvider provideEntityEnclosingInterfaceMethods */
 public function testEntityEnclosingInterfaceMethods($method, array $params = [])
 {
     $this->wrappedEntityEnclosingRequest->expects($this->once())->method($method)->will($this->returnValue('ENTITY_ENCL_REQ'))->getMatcher()->parametersMatcher = new ParametersMatcher($params);
     $this->assertSame('ENTITY_ENCL_REQ', call_user_func_array([$this->unifiedEnclosingEntityRequest, $method], $params));
     $this->wrappedRequest->expects($this->any())->method('getMethod')->will($this->returnValue('METHOD'));
     $this->wrappedRequest->expects($this->any())->method('getPath')->will($this->returnValue('/foo'));
     $this->setExpectedException('BadMethodCallException', sprintf('Cannot call method "%s" on a request that does not enclose an entity. Did you expect a POST/PUT request instead of METHOD /foo?', $method));
     call_user_func_array([$this->unifiedRequest, $method], $params);
 }
Example #2
0
 protected function setUp()
 {
     $this->mockRequest = $this->getMock('\\Guzzle\\Http\\Message\\RequestInterface');
     $this->mockResponse = $this->getMock('\\Guzzle\\Http\\Message\\Response', array(), array(), '', false);
     $this->mockRequest->expects($this->any())->method('send')->will($this->returnValue($this->mockResponse));
     $this->mockHttpClient = $this->getMock('\\Guzzle\\Http\\ClientInterface');
     $this->mockAuth = $this->getMock('\\Thismoment\\Signature', array(), array('secret'));
     $this->object = new \Thismoment\Api('cloud', 'key', 'secret', $this->mockHttpClient, $this->mockAuth);
 }
 /**
  * @param string $request
  * @param array $params
  * @param string $data
  */
 protected function buildDialogue($request, array $params, $data = '')
 {
     $this->client->expects($this->once())->method('get')->with($this->getUrl($request, $params))->will($this->returnValue($this->request));
     $this->request->expects($this->once())->method('setHeader')->with('User-Agent', $this->app_code)->will($this->returnValue($this->request));
     $this->request->expects($this->once())->method('send')->will($this->returnValue($this->response));
     $this->response->expects($this->once())->method('isError')->will($this->returnValue(!$data));
     if ($data) {
         $this->response->expects($this->once())->method('getBody')->with(true)->will($this->returnValue(gzencode($data)));
         $this->response_repair->expects($this->once())->method('repair')->with($data)->will($this->returnValue($data));
     } else {
         $this->response->expects($this->never())->method('getBody');
         $this->response_repair->expects($this->never())->method('repair');
     }
 }
Example #4
0
 /**
  * Response no body.
  */
 protected function responseNoBody()
 {
     $options = $this->getMock('\\Guzzle\\Common\\Collection');
     $options->expects($this->once())->method('set')->with(CURLOPT_NOBODY, true);
     $this->request->expects($this->once())->method('getCurlOptions')->will($this->returnValue($options));
 }