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