當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::expects方法代碼示例

本文整理匯總了PHP中Guzzle\Http\Message\Response::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::expects方法的具體用法?PHP Response::expects怎麽用?PHP Response::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Guzzle\Http\Message\Response的用法示例。


在下文中一共展示了Response::expects方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleErrorShouldRaiseExceptionWhenHostIsFromPagSeguro

 /**
  * @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);
 }
開發者ID:amaurymedeiros,項目名稱:pagseguro,代碼行數:13,代碼來源:ClientTest.php

示例2: setUp

 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']);
 }
開發者ID:robinbonnes,項目名稱:OroCRMMailChimpBundle,代碼行數:14,代碼來源:SyncMemberTest.php

示例3: buildDialogue

 /**
  * @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');
     }
 }
開發者ID:anime-db,項目名稱:ani-db-browser-bundle,代碼行數:19,代碼來源:BrowserTest.php

示例4: dialog

 /**
  * @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));
 }
開發者ID:anime-db,項目名稱:app-bundle,代碼行數:10,代碼來源:DownloaderTest.php


注:本文中的Guzzle\Http\Message\Response::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。