本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client::click方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::click方法的具体用法?PHP Client::click怎么用?PHP Client::click使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Client
的用法示例。
在下文中一共展示了Client::click方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例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: testEdit
public function testEdit()
{
$crawler = $this->client->request('GET', '/member');
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
$this->assertEquals(1, $crawler->filter('div.app_member_index')->count());
$this->assertGreaterThanOrEqual(1, $crawler->selectLink('Show')->count());
$crawler = $this->client->click($crawler->selectLink('Show')->first()->link());
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
$this->assertEquals(1, $crawler->filter('div.app_member_show')->count());
$this->assertGreaterThanOrEqual(1, $crawler->selectLink('Edit')->count());
$crawler = $this->client->click($crawler->selectLink('Edit')->first()->link());
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
$this->assertEquals(1, $crawler->filter('div.app_member_edit')->count());
}
示例4: logoutAction
/**
* Performs logout action and returns same client after log out.
*
* @param Client $client
*
* @return Client
*/
public function logoutAction(Client $client)
{
$crawler = $client->request('GET', '/settings/login');
$link = $crawler->filter('a:contains("Logout")')->link();
$client->click($link);
return $client;
}
示例5: pagination
/**
* @param Crawler $crawler
* @return boolean|Crawler
* TODO: Поиск записей по всем доступным страницам.
*/
protected function pagination(Crawler $crawler)
{
$nextPageCrawler = $crawler->selectLink('След.');
if ($nextPageCrawler && $nextPageCrawler->getNode(0) && false === mb_stripos($nextPageCrawler->getNode(0)->getAttribute('class'), 'ui-disabled', null, 'UTF-8')) {
return self::$client->click($nextPageCrawler->link());
}
return false;
}
示例6: testPreviewOwner
public function testPreviewOwner()
{
$pageEleveur = $this->testUtils->createUser()->toEleveur()->getPageEleveur();
$crawler = $this->client->request('GET', '/elevage/' . $pageEleveur->getSlug());
$this->assertContains(self::FLAG_JS_EDITABLE, $crawler->html());
$previewLink = $crawler->filter('#eleveur-toolbar #preview')->link();
$crawnlerPreview = $this->client->click($previewLink);
$this->assertNotContains(self::FLAG_JS_EDITABLE, $crawnlerPreview->html());
}
示例7: testLinkContact
public function testLinkContact()
{
$crawler = $this->client->request('GET', '/');
$this->client->click($crawler->filter('footer a[href="/contact"]')->link());
$this->assertEquals(Response::HTTP_OK, $this->client->getResponse()->getStatusCode());
}
示例8: _goToSummary
/**
* Moves forward to the summary page
*
* @param \Symfony\Bundle\FrameworkBundle\Client $client HTTP test client
* @return \Symfony\Component\DomCrawler\Crawler Crawler HTTP crawler
*/
protected function _goToSummary($client)
{
$crawler = $client->request('GET', '/unittest/de/EUR/list');
$link = $crawler->filter('.catalog-list-items .product a:contains("Unittest: Bundle")')->link();
$crawler = $client->click($link);
$form = $crawler->filter('.catalog-detail .addbasket .btn-action')->form();
$crawler = $client->submit($form);
$link = $crawler->filter('.basket-standard .btn-action')->link();
$crawler = $client->click($link);
$form = $crawler->filter('.checkout-standard form')->form();
$form['ca_billingoption']->select($crawler->filter('.checkout-standard-address .item-address input')->attr('value'));
$crawler = $client->submit($form);
$form = $crawler->filter('.checkout-standard form')->form();
$form['c_deliveryoption']->select($crawler->filter('.checkout-standard-delivery .item-service input')->attr('value'));
$crawler = $client->submit($form);
$form = $crawler->filter('.checkout-standard form')->form();
$form['c_paymentoption']->select($crawler->filter('.checkout-standard-payment .item-service input')->attr('value'));
$crawler = $client->submit($form);
return $crawler;
}
示例9: testLogIn
public function testLogIn()
{
$link = $this->crawler->filter('a:contains("Zaloguj się")')->link();
$log = $this->client->click($link);
$this->assertContains("Formularz logowania", $log->filter('.container h1')->text());
}
示例10: click
/**
* Clicks on a given link.
*
* @param Link $link A Link instance
*
* @return Crawler
*
* @api
*/
public function click(Link $link)
{
return $this->subject->click($link);
}