You are here

public function CrawlerTest::testLink in Zircon Profile 8.0

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

File

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

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testLink() {
  $crawler = $this
    ->createTestCrawler('http://example.com/bar/')
    ->selectLink('Foo');
  $this
    ->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $crawler
    ->link(), '->link() returns a Link instance');
  $this
    ->assertEquals('POST', $crawler
    ->link('post')
    ->getMethod(), '->link() takes a method as its argument');
  $crawler = $this
    ->createTestCrawler('http://example.com/bar')
    ->selectLink('GetLink');
  $this
    ->assertEquals('http://example.com/bar?get=param', $crawler
    ->link()
    ->getUri(), '->link() returns a Link instance');
  try {
    $this
      ->createTestCrawler()
      ->filterXPath('//ol')
      ->link();
    $this
      ->fail('->link() throws an \\InvalidArgumentException if the node list is empty');
  } catch (\InvalidArgumentException $e) {
    $this
      ->assertTrue(true, '->link() throws an \\InvalidArgumentException if the node list is empty');
  }
}