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


PHP Client::getRequest方法代码示例

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


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

示例1: 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');
     $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:rfc1483,项目名称:padel,代码行数:11,代码来源:ClientTest.php

示例2: it_passes_payload_to_token_translator

 /** @test */
 public function it_passes_payload_to_token_translator()
 {
     $iat = time();
     $mock = $this->getMock('Jsor\\Stack\\Stub\\CallableStub');
     $mock->expects($this->once())->method('__invoke')->with(['iat' => $iat] + $this->payload())->will($this->returnValue('foo'));
     $app = $this->createDecoratedApplication(['token_translator' => $mock]);
     $client = new Client($app);
     $client->request('GET', '/protected/token', [], [], ['HTTP_AUTHORIZATION' => sprintf('Bearer %s', $this->validToken(['iat' => $iat]))]);
     $this->assertSame('foo', $client->getRequest()->attributes->get('stack.authn.token'));
 }
开发者ID:jsor,项目名称:stack-jwt,代码行数:11,代码来源:SilexApplicationTest.php

示例3: testFormAuthentication

 public function testFormAuthentication()
 {
     $app = $this->createApplication('form');
     $client = new Client($app);
     $client->request('get', '/');
     $this->assertEquals('ANONYMOUS', $client->getResponse()->getContent());
     $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'bar'));
     $this->assertEquals('Bad credentials', $app['security.last_error']($client->getRequest()));
     // hack to re-close the session as the previous assertions re-opens it
     $client->getRequest()->getSession()->save();
     $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'foo'));
     $this->assertEquals('', $app['security.last_error']($client->getRequest()));
     $client->getRequest()->getSession()->save();
     $this->assertEquals(302, $client->getResponse()->getStatusCode());
     $this->assertEquals('http://localhost/', $client->getResponse()->getTargetUrl());
     $client->request('get', '/');
     $this->assertEquals('fabienAUTHENTICATED', $client->getResponse()->getContent());
     $client->request('get', '/admin');
     $this->assertEquals(403, $client->getResponse()->getStatusCode());
     $client->request('get', '/logout');
     $this->assertEquals(302, $client->getResponse()->getStatusCode());
     $this->assertEquals('http://localhost/', $client->getResponse()->getTargetUrl());
     $client->request('get', '/');
     $this->assertEquals('ANONYMOUS', $client->getResponse()->getContent());
     $client->request('get', '/admin');
     $this->assertEquals(302, $client->getResponse()->getStatusCode());
     $this->assertEquals('http://localhost/login', $client->getResponse()->getTargetUrl());
     $client->request('post', '/login_check', array('_username' => 'admin', '_password' => 'foo'));
     $this->assertEquals('', $app['security.last_error']($client->getRequest()));
     $client->getRequest()->getSession()->save();
     $this->assertEquals(302, $client->getResponse()->getStatusCode());
     $this->assertEquals('http://localhost/admin', $client->getResponse()->getTargetUrl());
     $client->request('get', '/');
     $this->assertEquals('adminAUTHENTICATEDADMIN', $client->getResponse()->getContent());
     $client->request('get', '/admin');
     $this->assertEquals('admin', $client->getResponse()->getContent());
 }
开发者ID:nekogami,项目名称:Silex,代码行数:37,代码来源:SecurityServiceProviderTest.php

示例4: testExposedExceptions

 public function testExposedExceptions()
 {
     $app = $this->createApplication('form');
     $app['security.hide_user_not_found'] = false;
     $client = new Client($app);
     $client->request('get', '/');
     $this->assertEquals('ANONYMOUS', $client->getResponse()->getContent());
     $client->request('post', '/login_check', array('_username' => 'fabien', '_password' => 'bar'));
     $this->assertEquals('The presented password is invalid.', $app['security.last_error']($client->getRequest()));
     $client->getRequest()->getSession()->save();
     $client->request('post', '/login_check', array('_username' => 'unknown', '_password' => 'bar'));
     $this->assertEquals('Username "unknown" does not exist.', $app['security.last_error']($client->getRequest()));
     $client->getRequest()->getSession()->save();
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:14,代码来源:SecurityServiceProviderTest.php

示例5: testUploadedFileWhenSizeExceedsUploadMaxFileSize

 public function testUploadedFileWhenSizeExceedsUploadMaxFileSize()
 {
     $source = tempnam(sys_get_temp_dir(), 'source');
     $kernel = new TestHttpKernel();
     $client = new Client($kernel);
     $file = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\File\\UploadedFile')->setConstructorArgs(array($source, 'original', 'mime/original', 123, UPLOAD_ERR_OK, true))->setMethods(array('getSize'))->getMock();
     $file->expects($this->once())->method('getSize')->will($this->returnValue(INF));
     $client->request('POST', '/', array(), array($file));
     $files = $client->getRequest()->files->all();
     $this->assertCount(1, $files);
     $file = $files[0];
     $this->assertFalse($file->isValid());
     $this->assertEquals(UPLOAD_ERR_INI_SIZE, $file->getError());
     $this->assertEquals('mime/original', $file->getClientMimeType());
     $this->assertEquals('original', $file->getClientOriginalName());
     $this->assertEquals(0, $file->getClientSize());
     unlink($source);
 }
开发者ID:goodvibrations,项目名称:workshome,代码行数:18,代码来源:ClientTest.php

示例6: resourceTypeDebugEndpointAction

 public function resourceTypeDebugEndpointAction(Request $request)
 {
     $parameters = array();
     $server = array('HTTP_Authorization' => implode(' ', array('Bearer', $request->query->get('access_token'))));
     $client = new Client($this->get('kernel'));
     $crawler = $client->request('GET', '/api/v1.0/resource/debug_endpoint', $parameters, array(), $server);
     $resourceResponse = json_decode($client->getResponse()->getContent(), true);
     $resourceRequest = get_object_vars($client->getRequest());
     return $this->render('TestBundle:demo/resource_type:debug_endpoint.html.twig', array('resource_response' => $resourceResponse, 'resource_request' => $resourceRequest));
 }
开发者ID:engru,项目名称:oauth2-symfony-bundle,代码行数:10,代码来源:DemoController.php

示例7: resourceTypeDebugEndpointAction

 public function resourceTypeDebugEndpointAction(Request $request, Application $app)
 {
     $parameters = [];
     $server = ['HTTP_Authorization' => implode(' ', ['Bearer', $request->query->get('access_token')])];
     $client = new Client($app);
     $crawler = $client->request('GET', '/api/resource/debug_endpoint', $parameters, [], $server);
     $resourceResponse = json_decode($client->getResponse()->getContent(), true);
     $resourceRequest = get_object_vars($client->getRequest());
     return $app['twig']->render('demo/resource_type/debug_endpoint.html.twig', ['resource_response' => $resourceResponse, 'resource_request' => $resourceRequest]);
 }
开发者ID:brunetvova,项目名称:oauth2-php,代码行数:10,代码来源:DemoController.php


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