本文整理汇总了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());
}
示例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();
}
示例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");
}
示例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');
}
示例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;
}
示例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());
}
示例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']);
}
示例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());
}
示例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() . ' ########');
}
示例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;
}
示例11: setUp
public function setUp()
{
parent::setUp();
$this->client = static::createClient();
$this->client->followRedirects();
}
示例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);
}