本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::followRedirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::followRedirect方法的具体用法?PHP Client::followRedirect怎么用?PHP Client::followRedirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Client
的用法示例。
在下文中一共展示了Client::followRedirect方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAsUser
/**
* @return Crawler
* @throws \Exception
*/
protected static function loginAsUser()
{
$uri = self::$container->get('router')->generate('login_route');
$crawler = self::$client->request('GET', $uri);
$form = $crawler->selectButton('login_btn')->form(['_username' => 'test', '_password' => '12345678']);
self::$client->submit($form);
self::assertTrue(self::$client->getResponse()->isRedirection());
return self::$client->followRedirect();
}
示例2: testOut
public function testOut()
{
$this->client->request('GET', '/');
$crawler = $this->client->followRedirect();
$link = $crawler->filter('a#logout')->eq(0)->link();
$this->client->click($link);
//suivre redirection vers page login quand click sur 'logout'
$this->assertEquals('Sonata\\UserBundle\\Controller\\SecurityFOSUser1Controller::logoutAction', $this->client->getRequest()->attributes->get('_controller'));
$this->assertEquals(302, $this->client->getResponse()->getStatusCode());
}
示例3: testAdd
public function testAdd()
{
$crawler = $this->client->request('GET', '/member/add');
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
$this->assertEquals(1, $crawler->filter('div.app_member_add')->count());
$this->assertEquals(1, $crawler->selectButton('add')->count());
$button = $crawler->selectButton('add')->first();
$form = $button->form(array('member[firstname]' => 'John', 'member[lastname]' => 'Doe', 'member[gender]' => 'm', 'member[birthday]' => '11/04/1980', 'member[birthplace]' => 'New-York City', 'member[address]' => 'Main street', 'member[zip]' => '01234', 'member[city]' => 'Washington D.C.'));
$form['member[photo]']->upload(__DIR__ . '/../../photo.jpg');
$this->client->submit($form);
$this->assertTrue($this->client->getResponse()->isRedirect());
$crawler = $this->client->followRedirect();
$this->assertEquals(1, $crawler->filter('div.flash.success')->count());
}
示例4: testCreationPageEleveur_Success
public function testCreationPageEleveur_Success()
{
// Création de compte
$user = $this->testUtils->createUser()->getUser();
// Formulaire de création de page eleveur
$crawler = $this->client->request('GET', '/');
$this->assertEquals('Nom de l\'élevage', $crawler->filter('form[name="creation-page-eleveur"] label')->text());
$this->assertEquals('Créer ma page éleveur', $crawler->filter('form[name="creation-page-eleveur"] [type="submit"]')->text());
$creationPageEleveurForm = $crawler->filter('form[name="creation-page-eleveur"]')->form();
$rand = rand();
$nomElevage = 'Les Chartreux de Tatouine ' . $rand;
$creationPageEleveurForm['creation-page-eleveur[nom]'] = $nomElevage;
$this->client->submit($creationPageEleveurForm);
// Redirection vers sa page eleveur fraichement créé
$this->assertEquals(302, $this->client->getResponse()->getStatusCode());
$this->client->followRedirect();
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertEquals('/elevage/les-chartreux-de-tatouine-' . $rand, $this->client->getRequest()->getRequestUri());
}
示例5: testConfirmation
public function testConfirmation()
{
$user = $this->testUtils->createUser()->getUser();
$crawler = $this->client->request('GET', '/contact');
$form = $crawler->filter('form')->form();
$form['form[message]'] = 'test';
$this->client->submit($form);
$this->assertEquals(Response::HTTP_FOUND, $this->client->getResponse()->getStatusCode());
$confirmationCrawler = $this->client->followRedirect();
$this->assertContains('Nous vous répondrons à l\'adresse ' . $user->getEmail(), $confirmationCrawler->filter('#confirmation')->text());
}
示例6: runTroughStep5
/**
* @param \Symfony\Component\DomCrawler\Crawler $crawler
* @param \Symfony\Bundle\FrameworkBundle\Client $client
*
* @return mixed
*/
private function runTroughStep5($crawler, $client)
{
$form = $crawler->selectButton('Finish installation')->form();
$client->submit($form, array('install_login[email]' => 'test@test.com', 'install_login[password][first]' => 'password', 'install_login[password][second]' => 'password'));
$crawler = $client->followRedirect();
// we should be redirected to step 6
self::assertEquals(200, $client->getResponse()->getStatusCode());
self::assertStringEndsWith('/install/6', $client->getHistory()->current()->getUri());
self::assertGreaterThan(0, $crawler->filter('h2:contains("Installation complete")')->count());
return $crawler;
}
示例7: testLogout
/**
* @depends testLogin
*/
public function testLogout(Client $client)
{
$this->setSecurityContextUser();
$crawler = $client->getCrawler();
$crawler = $client->request('GET', self::URL_DECONNECTION);
$this->assertEquals(302, $client->getResponse()->getStatusCode());
$this->assertEquals(self::URL_DECONNECTION, $client->getRequest()->getRequestUri());
$crawler = $client->followRedirect();
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertEquals('/en/', $client->getRequest()->getRequestUri());
}
示例8: logout
/**
* @param \Symfony\Bundle\FrameworkBundle\Client $client
* @return WebTestCase
*/
protected function logout(Client $client)
{
$client->request('GET', static::URL_DECONNECTION);
$client->followRedirect();
return $this;
}
示例9: assertIs404
/**
* @param Client $client
*/
protected function assertIs404($client)
{
$client->followRedirect();
$this->assertEquals(404, $client->getResponse()->getStatusCode());
$this->assertStringEndsWith('404', $client->getHistory()->current()->getUri());
}
示例10: followRedirect
/**
* Follow redirects?
*
* @return Crawler
*
* @throws \LogicException If request was not a redirect
*
* @api
*/
public function followRedirect()
{
return $this->subject->followRedirect();
}