當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。