当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getResponse方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Client::getResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getResponse方法的具体用法?PHP Client::getResponse怎么用?PHP Client::getResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Client的用法示例。


在下文中一共展示了Client::getResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makeRequest

 protected function makeRequest($method, $uri, $annotationOptions = array())
 {
     $this->getClient($annotationOptions);
     $this->client->request($method, $uri, array(), array(), $this->requestOptions);
     $response = $this->client->getResponse();
     return $response;
 }
开发者ID:jsmith07,项目名称:silex-annotation-provider,代码行数:7,代码来源:AnnotationTestBase.php

示例2: testLoginSuccess

 /**
  * test login
  */
 public function testLoginSuccess()
 {
     $data = array('username' => 'user', 'password' => 'password');
     $this->client->request('POST', $this->getUrl('api_login_check'), $data);
     $this->assertJsonResponse($this->client->getResponse(), 200);
     $response = json_decode($this->client->getResponse()->getContent(), true);
     $this->assertArrayHasKey('token', $response);
     // check token from query string work
     $client = static::createClient();
     $client->request('HEAD', $this->getUrl('api_ping', array($this->queryParameterName => $response['token'])));
     $this->assertJsonResponse($client->getResponse(), 200, false);
     // check token work
     $client = static::createClient();
     $client->setServerParameter('HTTP_Authorization', sprintf('%s %s', $this->authorizationHeaderPrefix, $response['token']));
     $client->request('HEAD', $this->getUrl('api_ping'));
     $this->assertJsonResponse($client->getResponse(), 200, false);
     // check token works several times, as long as it is valid
     $client = static::createClient();
     $client->setServerParameter('HTTP_Authorization', sprintf('%s %s', $this->authorizationHeaderPrefix, $response['token']));
     $client->request('HEAD', $this->getUrl('api_ping'));
     $this->assertJsonResponse($client->getResponse(), 200, false);
     // check a bad token does not work
     $client = static::createClient();
     $client->setServerParameter('HTTP_Authorization', sprintf('%s %s', $this->authorizationHeaderPrefix, $response['token'] . 'changed'));
     $client->request('HEAD', $this->getUrl('api_ping'));
     $this->assertJsonResponse($client->getResponse(), 401, false);
     // check error if no authorization header
     $client = static::createClient();
     $client->request('HEAD', $this->getUrl('api_ping'));
     $this->assertJsonResponse($client->getResponse(), 401, false);
 }
开发者ID:sev28,项目名称:flyaround_s2,代码行数:34,代码来源:ApiSecurityControllerTest.php

示例3: doLogin

 /**
  * Do login with username
  *
  * @param string $username
  */
 private function doLogin($username = 'admin')
 {
     $crawler = $this->client->request('GET', $this->getUrl('fos_user_security_login', array()));
     $form = $crawler->selectButton('_submit')->form(array('_username' => $username, '_password' => 'qwerty'));
     $this->client->submit($form);
     $this->assertTrue($this->client->getResponse()->isRedirect());
     $this->client->followRedirects();
 }
开发者ID:alienpham,项目名称:portfolio,代码行数:13,代码来源:UploadControllerTest.php

示例4: testLoginSuccess

 /**
  * test login
  */
 public function testLoginSuccess()
 {
     $data = array('username' => 'user', 'password' => 'password');
     $this->client->request('POST', $this->getUrl('login_check'), $data);
     $this->assertJsonResponse($this->client->getResponse(), 200);
     $response = json_decode($this->client->getResponse()->getContent(), true);
     $this->assertArrayHasKey('token', $response);
     $this->assertArrayHasKey('data', $response);
 }
开发者ID:jpsymfony,项目名称:REST-BEHAT,代码行数:12,代码来源:AuthenticationControllerTest.php

示例5: navigateToPageAndAssertSuccess

 /**
  * @param string $uri
  * @param string $responseType
  */
 public function navigateToPageAndAssertSuccess($uri, $responseType = null)
 {
     $this->client->request('GET', $uri);
     $this->assertTrue($this->client->getResponse()->isSuccessful(), 'Navigation to ' . $uri . ' did not trigger a successful response.');
     if (null !== $responseType) {
         $responseTypeIsTheOneExpected = $this->client->getResponse()->headers->contains('Content-Type', $responseType);
         $this->assertTrue($responseTypeIsTheOneExpected, 'The content type of the response was not ' . $responseType . '. The header provided was: ' . var_export($this->client->getResponse()->headers, true));
     }
 }
开发者ID:cegeka,项目名称:symfony-toolkit,代码行数:13,代码来源:FunctionalBase.php

示例6: testDoRequest

 public function testDoRequest()
 {
     $client = new Client(new TestHttpKernel());
     $client->request('GET', '/');
     $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
     $client->request('GET', 'http://www.example.com/');
     $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
     $this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request');
 }
开发者ID:notbrain,项目名称:symfony,代码行数:9,代码来源:ClientTest.php

示例7: assertLinkRel

 protected function assertLinkRel(Client $client, string $linkRel, string $expected)
 {
     $this->assertTrue($client->getResponse()->isSuccessful(), 'request is successful');
     foreach ($client->getResponse()->headers->get('Link', null, false) as $linkValue) {
         if (strpos($linkValue, 'rel="' . $linkRel . '"') !== false) {
             $this->assertSame($expected, $linkValue);
             return;
         }
     }
     $this->fail('No link with rel "' . $linkRel . '" found.');
 }
开发者ID:JeroenDeDauw,项目名称:QueryrAPI,代码行数:11,代码来源:ApiTestCase.php

示例8: testError

 /**
  * @dataProvider provideExceptionsAndCode
  */
 public function testError($exception, $code, $contentType)
 {
     $app = new Application('test');
     $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber(PhraseaExceptionHandler::register(), $this->createTranslatorMock()));
     $app->get('/api/oauthv2', function () use($exception) {
         throw $exception;
     });
     $client = new Client($app);
     $client->request('GET', '/api/oauthv2');
     $this->assertEquals($code, $client->getResponse()->getStatusCode());
     $this->assertEquals($contentType, $client->getResponse()->headers->get('content-type'));
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:15,代码来源:ApiOauth2ErrorsSubscriberTest.php

示例9: testRedirection

 public function testRedirection()
 {
     $app = new Application();
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new FirewallSubscriber());
     $app->get('/', function () {
         throw new HttpException(500, null, null, ['X-Phraseanet-Redirect' => '/hello-world']);
     });
     $client = new Client($app);
     $client->request('GET', '/');
     $this->assertEquals(302, $client->getResponse()->getStatusCode());
     $this->assertEquals('/hello-world', $client->getResponse()->headers->get('Location'));
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:13,代码来源:FirewallSubscriberTest.php

示例10: testCheckNegative

 public function testCheckNegative()
 {
     $app = new Application(Application::ENV_TEST);
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new MaintenanceSubscriber($app));
     $app->get('/', function () {
         return 'Hello';
     });
     $client = new Client($app);
     $client->request('GET', '/');
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $this->assertEquals('Hello', $client->getResponse()->getContent());
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:13,代码来源:MaintenanceSubscriberTest.php

示例11: logInBackend

 public function logInBackend($username = 'backenduser', $password = 'backenduser')
 {
     if ($this->um->isAuthenticated() === false) {
         $this->client->request('GET', '/' . $this->api['backend'] . '/user/login/?username=' . $username . '&password=' . $password, [], [], ['CONTENT_TYPE' => 'application/json']);
         $response = $this->client->getResponse();
         $content = $response->getContent();
         $result = json_decode($content, true);
         if ($result['status'] !== true) {
             throw new \LogicException('Authentication failed.');
         }
     }
     return $this->um->isAuthenticated();
 }
开发者ID:gitye,项目名称:Aisel,代码行数:13,代码来源:AbstractWebTestCase.php

示例12: logInFrontend

 public function logInFrontend($username = 'frontenduser', $password = 'frontenduser')
 {
     if ($this->um->isAuthenticated() === false) {
         $data = ['username' => $username, 'password' => $password];
         $this->client->request('POST', '/' . $this->api['frontend'] . '/user/login/', [], [], ['CONTENT_TYPE' => 'application/json'], json_encode($data));
         $response = $this->client->getResponse();
         $content = $response->getContent();
         $result = json_decode($content, true);
         if ($result['status'] !== true) {
             throw new \LogicException('Authentication failed.');
         }
     }
     return $this->um->isAuthenticated();
 }
开发者ID:Nameless0ne,项目名称:Aisel,代码行数:14,代码来源:AbstractWebTestCase.php

示例13: should_use_title_and_resources_if_html

 /**
  * @dataProvider dataProviderHTMLSyntax
  * @test
  */
 public function should_use_title_and_resources_if_html($syntax, $dir, $extension)
 {
     // GIVEN
     $this->app->register(new DocumentationProvider(), array("documentation.dir" => __DIR__ . "/datas/" . $dir, "documentation.url" => '/doc', "documentation.extension" => $extension, "documentation.home" => 'index', "documentation.syntax" => $syntax, "documentation.title" => 'My Documentation', "documentation.styles" => array('/components/bootstrap/css/bootstrap.min.css'), "documentation.scripts" => array('/components/jquery/jquery.min.js', '/components/bootstrap/js/bootstrap.min.js')));
     $client = new Client($this->app);
     // WHEN
     $crawler = $client->request('GET', '/doc');
     // THEN
     $this->assertTrue($client->getResponse()->isOk());
     $this->assertContains('text/html', $client->getResponse()->headers->get('Content-Type'));
     $this->assertCount(1, $crawler->filter("title"));
     $this->assertCount(1, $crawler->filter("link"));
     $this->assertCount(2, $crawler->filter("script"));
 }
开发者ID:mimiz,项目名称:silex-documentation-provider,代码行数:18,代码来源:DocumentationProviderTest.php

示例14: testDoRequest

 public function testDoRequest()
 {
     $client = new Client(new TestHttpKernel());
     $client->request('GET', '/');
     $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
     $this->assertInstanceOf('Symfony\\Component\\BrowserKit\\Request', $client->getInternalRequest());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Request', $client->getRequest());
     $this->assertInstanceOf('Symfony\\Component\\BrowserKit\\Response', $client->getInternalResponse());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $client->getResponse());
     $client->request('GET', 'http://www.example.com/');
     $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
     $this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request');
     $client->request('GET', 'http://www.example.com/?parameter=http://google.com');
     $this->assertEquals('http://www.example.com/?parameter=' . urlencode('http://google.com'), $client->getRequest()->getUri(), '->doRequest() uses the request handler to make the request');
 }
开发者ID:goodvibrations,项目名称:workshome,代码行数:15,代码来源:ClientTest.php

示例15: testListBucket

 public function testListBucket()
 {
     $this->authorize();
     $listUrl = $this->urlGenerator->generate('list', ['bucket' => 'foo']);
     $listBuckets = new Result(['Buckets' => [['Name' => 'foo', 'CreationDate' => '2014-08-01T14:00:00.000Z'], ['Name' => 'bar', 'CreationDate' => '2014-07-31T20:30:40.000Z']]]);
     $listObjects = new Result(['Contents' => [['Key' => 'baz', 'ETag' => '"' . md5('baz') . '"', 'LastModified' => '2014-09-10T11:12:13.000Z', 'Size' => 1024], ['Key' => 'qux', 'ETag' => '"' . md5('qux') . '"', 'LastModified' => '2014-09-11T21:22:23.000Z', 'Size' => 2048], ['Key' => 'quxx', 'ETag' => '"' . md5('quxx') . '"', 'LastModified' => '2014-09-12T00:00:00.000Z', 'Size' => 512]], 'IsTruncated' => false]);
     $this->s3ClientMock->expects($this->once())->method('listBuckets')->willReturn($listBuckets);
     $this->s3ClientMock->expects($this->once())->method('listObjects')->willReturn($listObjects);
     $crawler = $this->client->request('GET', $listUrl);
     $this->assertTrue($this->client->getResponse()->isOk());
     // buckets
     $list = $crawler->filter('#list-bucket li');
     $active = $list->filter('.active');
     $this->assertCount(count($listBuckets['Buckets']), $list);
     $this->assertCount(1, $active);
     $this->assertEquals($list->eq(0), $active);
     $urlGenerator = $this->urlGenerator;
     $list->each(function (Crawler $bucket, $index) use($urlGenerator, $listBuckets) {
         $link = $bucket->filter('a');
         $expectedName = $listBuckets['Buckets'][$index]['Name'];
         $this->assertEquals($expectedName, $link->text());
         $this->assertEquals($urlGenerator->generate('list', ['bucket' => $expectedName]), $link->attr('href'));
     });
     // objects
     $list = $crawler->filter('#list-object tbody tr');
     $this->assertCount(count($listObjects['Contents']), $list);
     $list->each(function (Crawler $object, $index) use($listObjects) {
         $link = $object->filter('td')->eq(0)->filter('a');
         $expectedKey = $listObjects['Contents'][$index]['Key'];
         $this->assertEquals($expectedKey, $link->text());
         $this->assertEquals('http://foo.s3.amazonaws.com/' . $expectedKey, $link->attr('href'));
         $this->assertEquals($listObjects['Contents'][$index]['Size'], $object->filter('td')->eq(1)->text());
     });
 }
开发者ID:ossinkine,项目名称:amazon-s3-client,代码行数:34,代码来源:ApplicationTest.php


注:本文中的Symfony\Component\HttpKernel\Client::getResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。