You are here

public function CrawlerTest::testAdd 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::testAdd()

@covers Symfony\Component\DomCrawler\Crawler::add

File

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

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testAdd() {
  $crawler = new Crawler();
  $crawler
    ->add($this
    ->createDomDocument());
  $this
    ->assertEquals('foo', $crawler
    ->filterXPath('//div')
    ->attr('class'), '->add() adds nodes from a \\DOMDocument');
  $crawler = new Crawler();
  $crawler
    ->add($this
    ->createNodeList());
  $this
    ->assertEquals('foo', $crawler
    ->filterXPath('//div')
    ->attr('class'), '->add() adds nodes from a \\DOMNodeList');
  foreach ($this
    ->createNodeList() as $node) {
    $list[] = $node;
  }
  $crawler = new Crawler();
  $crawler
    ->add($list);
  $this
    ->assertEquals('foo', $crawler
    ->filterXPath('//div')
    ->attr('class'), '->add() adds nodes from an array of nodes');
  $crawler = new Crawler();
  $crawler
    ->add($this
    ->createNodeList()
    ->item(0));
  $this
    ->assertEquals('foo', $crawler
    ->filterXPath('//div')
    ->attr('class'), '->add() adds nodes from a \\DOMElement');
  $crawler = new Crawler();
  $crawler
    ->add('<html><body>Foo</body></html>');
  $this
    ->assertEquals('Foo', $crawler
    ->filterXPath('//body')
    ->text(), '->add() adds nodes from a string');
}