Пример #1
0
 protected function getApiMock($constructor_args = array())
 {
     $httpClient = $this->getMock('Guzzle\\Http\\Client', array('send'));
     $httpClient->expects($this->any())->method('send');
     $mock = $this->getMock('Eloqua\\HttpClient\\HttpClient', array(), array(array(), $httpClient));
     $client = new \Eloqua\Client($mock);
     $client->setHttpClient($mock);
     return $this->getMockBuilder($this->getApiClass())->setMethods(array('get', 'post', 'postRaw', 'patch', 'delete', 'put'))->setConstructorArgs(array_merge(array($client), $constructor_args))->getMock();
 }
Пример #2
0
 /**
  * @test
  */
 public function shouldGetDataObject()
 {
     $api = new \Eloqua\Client();
     $api->setOption('version', '1.0');
     $this->assertInstanceOf('\\Eloqua\\Api\\Data\\CustomObject', $api->api('customObject')->data(1));
 }
 /**
  * Helper for getting AbstractBulkApi mock
  *
  * @param string $getResponseMethod
  *   Value to be passed to getResponse()
  *
  * @param mixed $getResponseValue
  *   Value to be returned from getResponse()
  *
  * @param string $setResponseMethod
  *   Value to be passed to setResponse()
  *
  * @param mixed $setResponseValue
  *   Value to be returned from setResponse()
  *
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 public function getBulkMock($getResponseMethod = null, $getResponseValue = null, $setResponseMethod = null, $setResponseValue = null)
 {
     $httpClient = $this->getMock('Guzzle\\Http\\Client', array('send'));
     $httpClient->expects($this->any())->method('send');
     $mock = $this->getMock('Eloqua\\HttpClient\\HttpClient', array(), array(array(), $httpClient));
     $client = new \Eloqua\Client($mock);
     $client->setHttpClient($mock);
     $bulkMock = $this->getMockForAbstractClass('Eloqua\\Api\\AbstractBulkApi', array($client), '', TRUE, TRUE, TRUE, array('post', 'get', 'setResponse', 'getResponse'));
     if (isset($getResponseMethod)) {
         $bulkMock->expects($this->once())->method('getResponse')->with($getResponseMethod, null)->will($this->returnValue($getResponseValue));
     }
     if (isset($setResponseMethod)) {
         $bulkMock->expects($this->once())->method('setResponse')->with($setResponseMethod, $setResponseValue)->will($this->returnValue($setResponseValue));
     }
     return $bulkMock;
 }