示例#1
0
 /**
  * Tests the requestApi function using GET as the httpMethod
  * @test
  */
 public function requestApiTestGET()
 {
     //Desired Results
     $responseBody = array('test' => true);
     $responseInfo = array('http_code' => 200, 'content_type' => 'test');
     $curlOpts = array(81 => false, 10002 => 'https://api.paymill.com/v2.1/', 19913 => true, 10036 => 'GET', 10018 => 'Paymill-php/0.0.2', 64 => true, 10005 => 'TestToken:');
     $this->_setMockProperties('_curlExec', $responseBody);
     $this->_setMockProperties('_curlInfo', $responseInfo);
     $that = $this;
     $this->_curlObject->expects($this->once())->method('_curlOpts')->will($this->returnCallback(function ($curl, array $options) use($curlOpts, $that) {
         $that->assertEquals($curlOpts, $options);
         return true;
     }));
     //Testing method using GET
     $result = $this->_curlObject->requestApi("", array(), 'GET');
     $this->assertEquals(array('header' => array('status' => $responseInfo['http_code'], 'reason' => null), 'body' => $responseBody), $result);
 }
示例#2
0
 /**
  * Prepares the mocked curl object to return any desired value for the given method
  * @param string $method
  * @param mixed $response
  */
 private function _setMockProperties($method, $response)
 {
     $this->_curlObject->expects($this->any())->method($method)->will($this->returnValue($response));
 }