Example #1
0
 /**
  * @test
  * @expectedException PHPSC\PagSeguro\Client\PagSeguroException
  */
 public function handleErrorShouldRaiseExceptionWhenHostIsFromPagSeguro()
 {
     $client = new Client($this->httpClient);
     $event = new Event(['request' => $this->request, 'response' => $this->response]);
     $this->request->expects($this->any())->method('getHost')->willReturn(Production::WS_HOST);
     $this->response->expects($this->any())->method('getStatusCode')->willReturn(401);
     $this->response->expects($this->any())->method('getBody')->willReturn('Unauthorized');
     $client->handleError($event);
 }
 protected function setUp()
 {
     $this->initClient();
     $this->clientFactory = $this->getMockBuilder('OroCRM\\Bundle\\MailChimpBundle\\Provider\\Transport\\MailChimpClientFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->apiClient = $this->getMockBuilder('OroCRM\\Bundle\\MailChimpBundle\\Provider\\Transport\\MailChimpClient')->disableOriginalConstructor()->setMethods(['export', 'getLists', 'getListMergeVars', 'getListStaticSegments'])->getMock();
     $this->clientFactory->expects($this->any())->method('create')->will($this->returnValue($this->apiClient));
     $this->entityBody = $this->getMockBuilder('Guzzle\\Http\\EntityBody\\EntityBody')->disableOriginalConstructor()->setMethods(['seek', 'readLine'])->getMock();
     $this->response = $this->getMockBuilder('Guzzle\\Http\\Message\\Response')->disableOriginalConstructor()->getMock();
     $this->apiClient->expects($this->any())->method('export')->will($this->returnValue($this->response));
     $this->response->expects($this->any())->method('getBody')->will($this->returnValue($this->entityBody));
     $transport = new MailChimpTransport($this->clientFactory, $this->getContainer()->get('doctrine'));
     $this->getContainer()->set('orocrm_mailchimp.transport.integration_transport', $transport);
     $this->loadFixtures(['OroCRM\\Bundle\\MailChimpBundle\\Tests\\Functional\\DataFixtures\\LoadStaticSegmentData']);
 }
 /**
  * @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
 /**
  * @param bool $is_successful
  * @param string $url
  */
 protected function dialog($is_successful = true, $url = '')
 {
     $this->response->expects($this->once())->method('isSuccessful')->will($this->returnValue($is_successful));
     $this->request->expects($this->once())->method('send')->will($this->returnValue($this->response));
     $this->client->expects($this->once())->method('get')->with($url ?: $this->url)->will($this->returnValue($this->request));
 }