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


PHP Client::getResponse方法代碼示例

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


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

示例1: authenticate

 /**
  * @return AuthenticateResponse
  */
 public function authenticate()
 {
     $this->client->request('POST', self::SING_IN_URI, ['username' => $this->username, 'password' => $this->password], [], ['HTTP_ACCEPT' => 'application/json']);
     $loginResponse = json_decode($this->client->getResponse()->getContent());
     $authenticateHeaders = ['HTTP_TOKEN' => isset($loginResponse->Token) ? $loginResponse->Token : null, 'HTTP_EXPIREAT' => isset($loginResponse->ExpireAt) ? $loginResponse->ExpireAt : null, 'HTTP_USERNAME' => isset($loginResponse->Username) ? $loginResponse->Username : null];
     return new AuthenticateResponse([], $authenticateHeaders);
 }
開發者ID:glavweb,項目名稱:rest-demo-app,代碼行數:10,代碼來源:Authenticator.php

示例2: getDocument

 /**
  * @param $uri
  * @param $format
  * @return \PHPExcel
  */
 protected function getDocument($uri, $format = 'xlsx')
 {
     // generate source
     static::$client->request('GET', $uri);
     $source = static::$client->getResponse()->getContent();
     // create source directory if necessary
     if (!file_exists(__DIR__ . static::$TEMP_PATH)) {
         mkdir(__DIR__ . static::$TEMP_PATH);
     }
     // save source
     file_put_contents(__DIR__ . static::$TEMP_PATH . 'simple' . '.' . $format, $source);
     // load source
     switch ($format) {
         case 'ods':
             $reader = new PHPExcel_Reader_OOCalc();
             break;
         case 'xls':
             $reader = new PHPExcel_Reader_Excel5();
             break;
         case 'xlsx':
             $reader = new PHPExcel_Reader_Excel2007();
             break;
         default:
             throw new InvalidArgumentException();
     }
     return $reader->load(__DIR__ . static::$TEMP_PATH . 'simple' . '.' . $format);
 }
開發者ID:darookee,項目名稱:TwigExcelBundle,代碼行數:32,代碼來源:AbstractControllerTest.php

示例3: testGetCategories

 public function testGetCategories()
 {
     $this->client->request('GET', '/search/categories');
     $response = $this->client->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $result = json_decode($response->getContent(), true);
     $this->assertContains('test', $result);
 }
開發者ID:kriswillis,項目名稱:sulu,代碼行數:8,代碼來源:SearchControllerTest.php

示例4: testGetIndexes

 public function testGetIndexes()
 {
     $this->client->request('GET', '/search/indexes');
     $response = $this->client->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $result = json_decode($response->getContent(), true);
     $this->assertEquals('product', $result[0]['indexName']);
 }
開發者ID:ollietb,項目名稱:sulu,代碼行數:8,代碼來源:SearchControllerTest.php

示例5: login

 protected function login(Client $client, $username = 'admin', $password = 'password')
 {
     $client->restart();
     $crawler = $client->request('GET', '/login');
     $this->assertTrue($client->getResponse()->isSuccessful(), 'Response should be successful');
     $form = $crawler->selectButton('Login')->form();
     $client->submit($form, array('_username' => $username, '_password' => $password));
     $this->assertTrue($client->getResponse()->isRedirect(), 'Response should be redirect');
     $crawler = $client->followRedirect();
     $this->assertGreaterThan(0, $crawler->filter('html:contains("Benvenuto")')->count());
 }
開發者ID:risinglf,項目名稱:UniversiBO,代碼行數:11,代碼來源:BaseControllerTest.php

示例6: seeResponseCodeIs

 /**
  * Checks response code.
  *
  * @param $num
  */
 public function seeResponseCodeIs($num)
 {
     if (method_exists($this->client->getResponse(), 'getStatusCode')) {
         \PHPUnit_Framework_Assert::assertEquals($num, $this->client->getResponse()->getStatusCode());
     } else {
         \PHPUnit_Framework_Assert::assertEquals($num, $this->client->getResponse()->getStatus());
     }
 }
開發者ID:pfz,項目名稱:codeception,代碼行數:13,代碼來源:REST.php

示例7: testSavePerDiemAction

 /**
  * testing savePerDiem action.
  */
 public function testSavePerDiemAction()
 {
     // Empty request
     $crawler = $this->client->request('POST', '/secured/travel/admin/save/perdiem');
     $this->assertJson($this->client->getResponse()->getContent(), 'testSavePerDiemAction: The response\'s content is not a JSON object.');
     $this->assertTrue($this->client->getResponse()->headers->contains('Content-Type', 'application/json'), 'testSavePerDiemAction: The content-type is not a json.');
     // Filled up request
     $crawler = $this->client->request('POST', '/secured/travel/admin/save/perdiem', array('perdiem' => array(0 => array('id' => 1, 'hours' => 14, 'amount' => 24), 1 => array('id' => null, 'hours' => 12, 'amount' => 12))));
     $this->assertTrue($this->client->getResponse()->headers->contains('Content-Type', 'text/html; charset=UTF-8'), 'testSavePerDiemAction: The content-type is not html.');
 }
開發者ID:hkmshb,項目名稱:OpitHrm,代碼行數:13,代碼來源:AdminControllerTest.php

示例8: grabTextFrom

 public function grabTextFrom($cssOrXPathOrRegex)
 {
     $nodes = $this->match($cssOrXPathOrRegex);
     if ($nodes) {
         return $nodes->first()->text();
     }
     if (@preg_match($cssOrXPathOrRegex, $this->client->getResponse()->getContent(), $matches)) {
         return $matches[1];
     }
     $this->fail("Element that matches '{$cssOrXPathOrRegex}' not found");
 }
開發者ID:NaszvadiG,項目名稱:ImageCMS,代碼行數:11,代碼來源:Framework.php

示例9: addToCart

 private function addToCart($mealName, $quantity, Crawler $crawler, Client $client)
 {
     $titles = $crawler->filter('h4')->reduce(function ($crawler) use($mealName) {
         return false !== strpos($crawler->text(), $mealName);
     });
     if (count($titles) !== 1) {
         throw new \RuntimeException(sprintf('Expected 1 title containing "%s", found %s.', $mealName, count($titles)));
     }
     $link = $titles->eq(0)->parents()->first()->filter('input[data-meal]');
     $mealId = $link->attr('data-meal');
     $client->request('POST', '/cart', array('meal' => $mealId, 'mode' => 'add', 'quantity' => $quantity));
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
 }
開發者ID:sroze,項目名稱:site-de-maman,代碼行數:13,代碼來源:CartControllerTest.php

示例10: sendXMLRPCMethodCall

 /**
  * Sends a XMLRPC method call to remote XMLRPC-server.
  *
  * @param string $methodName
  * @param array $parameters
  */
 public function sendXMLRPCMethodCall($methodName, $parameters = array())
 {
     if (!array_key_exists('Content-Type', $this->headers)) {
         $this->headers['Content-Type'] = 'text/xml';
     }
     foreach ($this->headers as $header => $val) {
         $this->client->setServerParameter("HTTP_{$header}", $val);
     }
     $url = $this->config['url'];
     if (is_array($parameters)) {
         $parameters = $this->scalarizeArray($parameters);
     }
     $requestBody = xmlrpc_encode_request($methodName, array_values($parameters));
     $this->debugSection('Request', $url . PHP_EOL . $requestBody);
     $this->client->request('POST', $url, array(), array(), array(), $requestBody);
     $this->response = $this->client->getResponse()->getContent();
     $this->debugSection('Response', $this->response);
 }
開發者ID:NaszvadiG,項目名稱:ImageCMS,代碼行數:24,代碼來源:XMLRPC.php

示例11: getResponse

 /**
  * {@inheritdoc}
  *
  * @return Response|null A Response instance
  */
 public function getResponse()
 {
     return parent::getResponse();
 }
開發者ID:omusico,項目名稱:lafayettehelps.com,代碼行數:9,代碼來源:Client.php

示例12: createNote

 protected function createNote(Client $client, $message)
 {
     $client->request('POST', '/notes.json', array('note' => array('message' => $message)));
     $response = $client->getResponse();
     $this->assertJsonResponse($response, Response::HTTP_CREATED);
 }
開發者ID:jeremyadoux,項目名稱:testSF2,代碼行數:6,代碼來源:NoteControllerTest.php

示例13: getXml

 /**
  * @return SimpleXMLElement
  * @param Client $client
  */
 protected function getXml()
 {
     $xml = new SimpleXMLElement($this->client->getResponse()->getContent());
     $this->ns->registerNamespaces($xml);
     return $xml;
 }
開發者ID:ubermichael,項目名稱:pkppln-php,代碼行數:10,代碼來源:AbstractSwordTestCase.php

示例14: makeRequest

 /**
  * @param $url
  * @param $data
  * @return Response
  */
 protected function makeRequest($url, $data)
 {
     $this->client->request('POST', $url, [], [], [], json_encode($data));
     return Response::jsonUnserialize($this->client->getResponse()->getContent());
 }
開發者ID:jced-artem,項目名稱:test_game,代碼行數:10,代碼來源:UserControllerTest.php

示例15: assertJsonResponse

 /**
  * @param string $expectedJson
  */
 protected function assertJsonResponse($expectedJson)
 {
     $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
     $this->assertEquals($expectedJson, $this->client->getResponse()->getContent());
 }
開發者ID:gsdevme,項目名稱:CraueFormFlowBundle,代碼行數:8,代碼來源:IntegrationTestCase.php


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