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


PHP Client::getResponse方法代碼示例

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


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

示例1: testControllerNoticeToException

 public function testControllerNoticeToException()
 {
     $this->client = $this->createClient();
     $errorOccured = false;
     $syslogProcessorMock = $this->getMockBuilder('Keboola\\Syrup\\Monolog\\Processor\\SyslogProcessor')->disableOriginalConstructor()->getMock();
     $syslogProcessorMock->expects($this->any())->method("processRecord")->with($this->callback(function ($subject) use(&$errorOccured) {
         if ($subject['message'] == 'Notice: Undefined offset: 3') {
             $e = $subject['context']['exception'];
             $errorOccured = true;
             return $e instanceof \Symfony\Component\Debug\Exception\ContextErrorException;
         }
         return true;
     }))->willReturn(['level' => 100]);
     $container = $this->client->getContainer();
     $container->set('syrup.monolog.syslog_processor', $syslogProcessorMock);
     $this->client->request('GET', '/tests/notice');
     $response = $this->client->getResponse();
     $responseJson = json_decode($response->getContent(), true);
     $this->assertEquals('error', $responseJson['status']);
     $this->assertEquals('Application error', $responseJson['error']);
     $this->assertEquals(500, $responseJson['code']);
     $this->assertArrayHasKey('exceptionId', $responseJson);
     $this->assertArrayHasKey('runId', $responseJson);
     $this->assertTrue($errorOccured);
 }
開發者ID:keboola,項目名稱:syrup,代碼行數:25,代碼來源:ErrorHandlingTest.php

示例2: testDeleteMultiple

 /**
  * @depends testPut
  */
 public function testDeleteMultiple()
 {
     $data = [2, 3];
     $uri = self::$router->generate('post_assets') . '.json';
     self::$client->request('DELETE', $uri, ['images' => json_encode($data)]);
     $this->assertTrue(self::$client->getResponse()->isRedirect());
 }
開發者ID:gorvelyfab,項目名稱:KoopaBaseAdminer,代碼行數:10,代碼來源:MediaControllerTest.php

示例3: testSearchPage

 public function testSearchPage()
 {
     $this->client->request('GET', '/search?keyword=samsung sync master');
     $response = $this->client->getResponse();
     $this->assertTrue($response->isSuccessful());
     $this->assertEquals('application/json', $response->headers->get('Content-Type'));
 }
開發者ID:uikolas,項目名稱:LT-eshops-search,代碼行數:7,代碼來源:DefaultControllerTest.php

示例4: testTokenCreation

 /**
  * Test token creation and usage
  */
 public function testTokenCreation()
 {
     $headers = array('PHP_AUTH_USER' => 'test_key', 'PHP_AUTH_PW' => 'test_secret', 'HTTP_username' => 'p-admin', 'HTTP_password' => 'p-admin');
     $this->client->request('GET', '/oauth/access_token?grant_type=password', array(), array(), $headers);
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
     $this->assertSame('application/json', $this->client->getResponse()->headers->get('content-type'));
 }
開發者ID:open-orchestra,項目名稱:open-orchestra,代碼行數:10,代碼來源:AuthorizationControllersTest.php

示例5: testPutPlayerAction

 public function testPutPlayerAction()
 {
     $em = self::$kernel->getContainer()->get('doctrine')->getManager();
     $queryBuilder = $em->createQueryBuilder();
     $players = $queryBuilder->select('p')->from('DraftBundle:Player', 'p')->setMaxResults(1)->getQuery()->execute();
     if (is_array($players)) {
         $player = $players[0];
     } else {
         $player = $players;
     }
     $name = $player->getName();
     $team = $player->getNflTeam();
     $position = $player->getPosition();
     $toEncode = array('name' => 'willy wonka', 'position' => 'QB', 'nflTeam' => 'SF', 'draftYear' => '2016');
     $postData = json_encode($toEncode);
     $this->client->request('PUT', '/api/players/' . $player->getId(), array(), array(), array('CONTENT_TYPE' => 'application/json'), $postData);
     $response = $this->client->getResponse();
     $content = $response->getContent();
     $this->assertTrue($response->isSuccessful());
     $this->assertEmpty($content);
     $updatedPlayer = $em->getRepository('DraftBundle:Player')->find($player->getId());
     $this->assertEquals('willy wonka', $updatedPlayer->getName());
     $updatedPlayer->setName($name);
     $updatedPlayer->setNflTeam($team);
     $updatedPlayer->setPosition($position);
     $em->persist($updatedPlayer);
     $em->flush();
 }
開發者ID:buphmin,項目名稱:RookieDraft,代碼行數:28,代碼來源:PlayerControllerTest.php

示例6: assertApiGetResponse

 protected function assertApiGetResponse($apiUri, $expectedStatusCode, $expectedJsonString)
 {
     static::$client->request('GET', $apiUri);
     $this->assertStatusCode($expectedStatusCode, static::$client);
     $responseBody = static::$client->getResponse()->getContent();
     static::assertJson($responseBody);
     static::assertJsonStringEqualsJsonString($expectedJsonString, $responseBody);
 }
開發者ID:RedDevilHat,項目名稱:symfony2,代碼行數:8,代碼來源:ApiTestCase.php

示例7: open

 /**
  * @param string $method
  * @param array $parameters
  * @return Page
  */
 public function open($method = 'GET', $parameters = [])
 {
     $this->crawler = $this->client->request($method, $this->unmaskUrl($parameters));
     if (!in_array($this->client->getResponse()->getStatusCode(), [200, 302])) {
         throw new \RuntimeException(sprintf("Can't open \"%s\"", $this->getUrl()));
     }
     return $this;
 }
開發者ID:karion,項目名稱:mydrinks,代碼行數:13,代碼來源:BasePage.php

示例8: loginAsUser

 /**
  * @return Crawler
  * @throws \Exception
  */
 protected static function loginAsUser()
 {
     $uri = self::$container->get('router')->generate('login_route');
     $crawler = self::$client->request('GET', $uri);
     $form = $crawler->selectButton('login_btn')->form(['_username' => 'test', '_password' => '12345678']);
     self::$client->submit($form);
     self::assertTrue(self::$client->getResponse()->isRedirection());
     return self::$client->followRedirect();
 }
開發者ID:Gemorroj,項目名稱:forum,代碼行數:13,代碼來源:ForumWebTestCase.php

示例9: callApi

 /**
  * Request to API, return result
  * @param string $url URL of API call
  * @param string $method HTTP method of API call
  * @param array $params parameters of POST call
  * @return array
  */
 protected function callApi($url, $method = 'POST', $params = array())
 {
     $this->httpClient->request($method, $url, [], [], [], json_encode($params));
     $response = $this->httpClient->getResponse();
     /* @var \Symfony\Component\HttpFoundation\Response $response */
     $responseJson = json_decode($response->getContent(), true);
     $this->assertNotEmpty($responseJson, sprintf("Response of API call '%s' after json decoding should not be empty. Raw response:\n%s\n", $url, $response->getContent()));
     return $responseJson;
 }
開發者ID:ErikZigo,項目名稱:syrup,代碼行數:16,代碼來源:AbstractFunctionalTest.php

示例10: callApiGet

 protected function callApiGet($url = null, $data = array(), $requiredHttpCode = 200)
 {
     $method = 'GET';
     $this->httpClient->request($method, $url, array());
     $response = $this->httpClient->getResponse();
     $this->assertEquals($requiredHttpCode, $response->getStatusCode(), sprintf(AbstractTest::ERROR_HTTP_CODE, $method, $url, $response->getContent()));
     $responseJson = json_decode($response->getContent(), true);
     //		$this->assertNotEmpty($responseJson, sprintf(self::ERROR_EMPTY_REPONSE, $method, $url));
     return $responseJson;
 }
開發者ID:keboola,項目名稱:orchestrator-bundle,代碼行數:10,代碼來源:DocumentationTest.php

示例11: testOut

 public function testOut()
 {
     $this->client->request('GET', '/');
     $crawler = $this->client->followRedirect();
     $link = $crawler->filter('a#logout')->eq(0)->link();
     $this->client->click($link);
     //suivre redirection vers page login quand click sur 'logout'
     $this->assertEquals('Sonata\\UserBundle\\Controller\\SecurityFOSUser1Controller::logoutAction', $this->client->getRequest()->attributes->get('_controller'));
     $this->assertEquals(302, $this->client->getResponse()->getStatusCode());
 }
開發者ID:WildCodeSchool,項目名稱:projet-gesty,代碼行數:10,代碼來源:ProfileController___.php

示例12: testFeed

 /**
  * Test for AppBundle\Controller\DefaultController::feedAction
  * Also test performance - Any PHP used should be limited to 32MB of memory
  *
  * @param string  $source
  * @param integer $start
  * @param integer $amount
  * @param integer $expectedAmount
  *
  * @dataProvider feedDataProvider
  */
 public function testFeed($source, $start, $amount, $expectedAmount)
 {
     $this->client->request('GET', '/feed', array('source' => $source, 'start' => $start, 'amount' => $amount));
     $response = $this->client->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('application/json', $response->headers->get('Content-type'));
     $this->assertCount($expectedAmount, json_decode($response->getContent(), true));
     $this->assertLessThan(1024 * 1024 * 32, memory_get_peak_usage(true));
     // 32 MB
 }
開發者ID:strannik-06,項目名稱:feed-reader,代碼行數:21,代碼來源:DefaultControllerTest.php

示例13: __doRequest

 /**
  * Overridden _doRequest method
  *
  * @param string $request
  * @param string $location
  * @param string $action
  * @param int $version
  * @param int $one_way
  *
  * @return string
  */
 public function __doRequest($request, $location, $action, $version, $one_way = 0)
 {
     //save directly in _SERVER array
     $_SERVER['HTTP_SOAPACTION'] = $action;
     $_SERVER['CONTENT_TYPE'] = 'application/soap+xml';
     //make POST request
     $this->client->request('POST', (string) $location, array(), array(), array(), (string) $request);
     unset($_SERVER['HTTP_SOAPACTION']);
     unset($_SERVER['CONTENT_TYPE']);
     return $this->client->getResponse()->getContent();
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:22,代碼來源:SoapClient.php

示例14: run

 public final function run()
 {
     $this->prepareDataForRequest();
     $this->makeRequest();
     $this->response = $this->client->getResponse();
     $this->testResponse($this->response);
     /* Вот этого тут так не должно быть... нельзя жестко завязываться на JSON'e, но пока ситуация терпит */
     $this->responseDataObject = json_decode($this->client->getResponse()->getContent(), false, 512, JSON_BIGINT_AS_STRING);
     $this->testResponseData($this->responseDataObject);
     $this->testResponseDataWithDataAsserterCallbacks();
 }
開發者ID:amstaffix,項目名稱:extjs-rest-common-bundle,代碼行數:11,代碼來源:Action.php

示例15: getAccessToken

 /**
  * @return mixed
  */
 protected function getAccessToken()
 {
     if (!array_key_exists($this->getUsername(), $this->accessToken)) {
         $headers = array('PHP_AUTH_USER' => 'test_key', 'PHP_AUTH_PW' => 'test_secret', 'HTTP_username' => $this->getUsername(), 'HTTP_password' => $this->getPassword());
         $this->client->request('GET', '/oauth/access_token?grant_type=password', array(), array(), $headers);
         $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
         $this->assertSame('application/json', $this->client->getResponse()->headers->get('content-type'));
         $tokenReponse = json_decode($this->client->getResponse()->getContent(), true);
         $this->accessToken[$this->getUsername()] = $tokenReponse['access_token'];
     }
     return $this->accessToken[$this->getUsername()];
 }
開發者ID:open-orchestra,項目名稱:open-orchestra,代碼行數:15,代碼來源:AbstractAuthenticatedTest.php


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