本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::getRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getRequest方法的具体用法?PHP Client::getRequest怎么用?PHP Client::getRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Client
的用法示例。
在下文中一共展示了Client::getRequest方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRegisterSuccess
public function testRegisterSuccess()
{
$this->form[self::USERNAME_FIELD] = self::USERNAME;
$this->form[self::EMAIL_FIELD] = self::EMAIL;
$this->form[self::PASSWORD_FIELD] = self::PASSWORD;
$this->form[self::REPEAT_PASSWORD_FIELD] = self::PASSWORD;
$this->crawler = $this->client->submit($this->form);
$this->assertEmpty($this->crawler->filter(self::ERROR_SELECTOR));
$this->assertNotEquals(self::REGISTRATION_URL, $this->client->getRequest()->getRequestUri());
}
示例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: 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());
}
示例4: 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());
}
示例5: assertSEOCompatible
protected function assertSEOCompatible(Client $client, $type = 'article')
{
$crawler = $client->getCrawler();
$url = $client->getRequest()->getUri();
$title = $crawler->filter('title')->text();
// title
$this->assertNotEmpty($title, 'The title is empty.');
// meta
$this->assertCount(1, $crawler->filter('meta[charset=UTF-8]'));
$this->assertCount(1, $crawler->filter('meta[property="og:title"][content="' . $title . '"]'));
$this->assertCount(1, $crawler->filter('meta[property="og:type"][content="' . $type . '"]'));
$this->assertCount(1, $crawler->filter('meta[property="og:url"][content="' . $url . '"]'));
// img
// $this->assertCount(0, $crawler->filter('img[alt=""]'));
$crawler->filter('img:not([alt])')->each(function ($node, $i) {
$this->assertTrue(false, 'An image with no alt attribute has been found src=' . $node->attr('src'));
});
}
示例6: printLastResponse
/**
* @Then print last response
*/
public function printLastResponse()
{
$response = $this->client->getResponse();
$request = $this->client->getRequest();
printf("%s %d %s\n%s", $request->getMethod(), $response->getStatusCode(), $request->getUri(), $response->getContent());
}
示例7: getRequest
/**
* Returns the current origin Request instance.
*
* The origin request is the request instance that is sent
* to the code that handles requests.
*
* @return object|null A Request instance
*
* @see doRequest()
*
* @api
*/
public function getRequest()
{
return $this->subject->getRequest();
}