You are here

public function CrawlerTest::testSelectLinkAndLinkFiltered in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Tests/CrawlerTest.php \Symfony\Component\DomCrawler\Tests\CrawlerTest::testSelectLinkAndLinkFiltered()

File

vendor/symfony/dom-crawler/Tests/CrawlerTest.php, line 755

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testSelectLinkAndLinkFiltered() {
  $html = <<<HTML
<!DOCTYPE html>
<html lang="en">
<body>
    <div id="action">
        <a href="/index.php?r=site/login">Login</a>
    </div>
    <form id="login-form" action="/index.php?r=site/login" method="post">
        <button type="submit">Submit</button>
    </form>
</body>
</html>
HTML;
  $crawler = new Crawler($html);
  $filtered = $crawler
    ->filterXPath("descendant-or-self::*[@id = 'login-form']");
  $this
    ->assertCount(0, $filtered
    ->selectLink('Login'));
  $this
    ->assertCount(1, $filtered
    ->selectButton('Submit'));
  $filtered = $crawler
    ->filterXPath("descendant-or-self::*[@id = 'action']");
  $this
    ->assertCount(1, $filtered
    ->selectLink('Login'));
  $this
    ->assertCount(0, $filtered
    ->selectButton('Submit'));
  $this
    ->assertCount(1, $crawler
    ->selectLink('Login')
    ->selectLink('Login'));
  $this
    ->assertCount(1, $crawler
    ->selectButton('Submit')
    ->selectButton('Submit'));
}