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


PHP Client::followRedirects方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->client = static::createClient();
     $this->client->followRedirects();
     $this->container = $this->client->getContainer();
     $this->loadFixtures($this->getFixtures());
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:7,代码来源:AbstractControllerTest.php

示例2: setUp

 protected function setUp()
 {
     $this->client = static::createClient();
     $this->client->followRedirects(true);
     $this->crawler = $this->client->request('GET', self::REGISTRATION_URL);
     $this->form = $this->crawler->selectButton(self::SUBMIT_BUTTON)->form();
 }
开发者ID:GrossumUA,项目名称:Symfony3-Base-Instance,代码行数:7,代码来源:RegistrationControllerTest.php

示例3: testAnonymousUrl

 /**
  * @dataProvider provideAnonymousUrls
  * @coversNothing
  *
  * @param string $url
  * @param string $expectedText
  */
 public function testAnonymousUrl($url, $expectedText)
 {
     self::$client = static::createClient();
     self::$client->followRedirects();
     $crawler = self::$client->request('GET', $url);
     $this->assertEquals(200, self::$client->getResponse()->getStatusCode(), 'Ensure status is 200');
     $this->assertEquals(1, $crawler->filter('html:contains("' . $expectedText . '")')->count(), "The text '{$expectedText}' should be present in the HTML page");
 }
开发者ID:WildCodeSchool,项目名称:projet-gesty,代码行数:15,代码来源:RouteTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->client = static::createClient();
     $this->client->followRedirects();
     $this->kern = $this->client->getKernel();
     $this->container = $this->client->getContainer();
     $this->em = $this->container->get('doctrine.orm.entity_manager');
 }
开发者ID:Reallymute,项目名称:IRMApplicative,代码行数:9,代码来源:CarmaWebTestCase.php

示例5: loginUsingFormUser

 /**
  * Use this function to connect to user in the application using login form
  * MORE SLOW, Use connectUser function above instead
  *
  * @param $username
  * @param $password
  * @return Client
  */
 protected function loginUsingFormUser($username, $password)
 {
     $this->client = static::createClient();
     $this->crawler = $this->client->request('GET', '/login');
     $credentials = array('_username' => $username, '_password' => $password);
     $form = $this->crawler->selectButton('_submit')->form($credentials);
     $this->client->submit($form);
     $this->client->followRedirects();
     return $this->client;
 }
开发者ID:TechGameCrew,项目名称:GyverProject,代码行数:18,代码来源:BaseTestCase.php

示例6: testLogin

 /**
  * @dataProvider provideLoginData
  */
 public function testLogin(Client $client, $securedUrl, $login, $expectedMessage)
 {
     // client follow redirects
     $client->followRedirects();
     // go to secured page -> got login required
     $crawler = $client->request('GET', $securedUrl);
     $this->assertEquals(TrustedSsoController::LOGIN_REQUIRED_MESSAGE, $crawler->filter('#message')->text());
     // click link -> got login form
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals('login', $crawler->filter('form')->attr('id'));
     // fill form & submit -> got expected message
     $form = $crawler->filter('input[type=submit]')->form();
     $crawler = $client->submit($form, array('login[username]' => $login, 'login[password]' => $login));
     $this->assertEquals($expectedMessage, $crawler->filter('#message')->text());
     if (!$login === self::LOGIN_INVALID) {
         // check validation attributes
         $attrs = static::$kernel->getContainer()->get('security.context')->getToken()->getValidationAttributes();
         $this->assertEquals(array('attr1' => 'val1', 'attr2' => 'val2'), $attrs);
     }
     // logout -> got logout redirect
     $crawler = $client->request('GET', '/secured/logout');
     $this->assertEquals(TrustedSsoController::LOGOUT_REDIRECT_MESSAGE, $crawler->filter('#message')->text());
     // click link -> got logout done
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals(ServerController::LOGOUT_MESSAGE, $crawler->filter('#message')->text());
     // click link -> go to homepage
     $crawler = $client->click($crawler->filter('#url')->link());
     $this->assertEquals(TestController::HOME_MESSAGE, $crawler->filter('#message')->text());
 }
开发者ID:nicolasbui,项目名称:BeSimpleSsoAuthBundle,代码行数:32,代码来源:LoginTest.php

示例7: testExternalLink

 /**
  * External
  */
 public function testExternalLink()
 {
     $this->createConfig();
     $this->createAccount();
     $referrerUrl = self::$client->getContainer()->get('router')->generate('keboola_google_analytics_external_auth_finish', array(), true);
     self::$client->followRedirects();
     self::$client->request('POST', '/ex-google-analytics/external-link', array(), array(), array(), json_encode(array('account' => 'test', 'referrer' => $referrerUrl)));
     $responseJson = self::$client->getResponse()->getContent();
     $response = json_decode($responseJson, true);
     $this->assertArrayHasKey('link', $response);
     $this->assertNotEmpty($response['link']);
 }
开发者ID:keboola,项目名称:google-analytics-bundle,代码行数:15,代码来源:ExtractorTest.php

示例8: testDeletePost

 public function testDeletePost()
 {
     $data = array('_csrf_token' => 'testtoken', 'content' => 'Test content', 'title' => 'test title');
     $this->client->getCookieJar()->set(new Cookie('cookie_csrf', 'testtoken'));
     $this->client->followRedirects(true);
     /** @var Crawler $crawler */
     $crawler = $this->jsonRequest('PUT', '/api/posts/1', $data);
     $this->assertJsonResponse($this->client->getResponse(), 201);
     $this->assertEmpty($this->client->getResponse()->getContent());
     /** @var Crawler $crawler */
     $crawler = $this->jsonRequest('DELETE', '/api/posts/1', $data);
     $this->assertEquals(204, $this->client->getResponse()->getStatusCode());
 }
开发者ID:snieditions,项目名称:rest-api,代码行数:13,代码来源:PostsControllerTest.php

示例9: setUp

 /**
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     if (isset($this->client)) {
         $this->client = null;
         unset($this->client);
     }
     $this->client = $this->createClient();
     //XXX: Follow this bug : https://github.com/symfony/symfony/issues/1726
     //$this->client->insulate();
     //Redirections is forced by default
     $this->client->followRedirects();
     //Session is invalidated
     $session = $this->client->getContainer()->get('session');
     if (isset($session)) {
         $session->invalidate();
     }
     $this->em = $this->client->getContainer()->get('doctrine')->getEntityManager();
     $this->t = $this->client->getContainer()->get('translator');
     $this->logger = $this->client->getContainer()->get('logger');
     $this->router = $this->client->getContainer()->get('router');
     $this->logger->info('######## Starting ' . $this->getName() . ' at ' . time() . ' ########');
 }
开发者ID:alterphp,项目名称:components,代码行数:26,代码来源:WebTestCase.php

示例10: login

 /**
  * @param \Symfony\Bundle\FrameworkBundle\Client $client
  * @param bool                                   $asAdmin
  *
  * @return User
  */
 public function login($client, $asAdmin = false)
 {
     $testUser = $asAdmin ? $this->createLoginAdminUser() : $this->createLoginUser();
     $username = $testUser->getUsername();
     $passwort = $testUser->getPlainPassword();
     $this->saveInDb([$testUser]);
     $crawler = $client->request('GET', '/login');
     $client->followRedirects();
     $loginForm = $crawler->selectButton('_submit')->form();
     $loginForm['_username'] = $username;
     $loginForm['_password'] = $passwort;
     $crawler = $client->submit($loginForm);
     $this->assertFalse((bool) $crawler->filter('.form-signin')->count(), "Can't Login User.");
     return $testUser;
 }
开发者ID:TumTum,项目名称:TrolleyAgenda,代码行数:21,代码来源:webClientUserLoginTrait.php

示例11: setUp

 public function setUp()
 {
     parent::setUp();
     $this->client = static::createClient();
     $this->client->followRedirects();
 }
开发者ID:petrepatrasc,项目名称:reading-group-challenges,代码行数:6,代码来源:AbstractFunctionalTest.php

示例12: followRedirects

 /**
  * Sets whether to automatically follow redirects or not.
  *
  * @param bool $followRedirect Whether to follow redirects
  *
  * @api
  */
 public function followRedirects($followRedirect = true)
 {
     $this->subject->followRedirects($followRedirect);
 }
开发者ID:kleijnweb,项目名称:swagger-bundle,代码行数:11,代码来源:ApiTestClient.php


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