You are here

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

File

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

Class

CrawlerTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testPreviousAll() {
  $crawler = $this
    ->createTestCrawler()
    ->filterXPath('//li')
    ->eq(2);
  $this
    ->assertNotSame($crawler, $crawler
    ->previousAll(), '->previousAll() returns a new instance of a crawler');
  $this
    ->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->previousAll() returns a new instance of a crawler');
  $nodes = $crawler
    ->previousAll();
  $this
    ->assertEquals(2, $nodes
    ->count());
  $this
    ->assertEquals('Two', $nodes
    ->eq(0)
    ->text());
  try {
    $this
      ->createTestCrawler()
      ->filterXPath('//ol')
      ->previousAll();
    $this
      ->fail('->previousAll() throws an \\InvalidArgumentException if the node list is empty');
  } catch (\InvalidArgumentException $e) {
    $this
      ->assertTrue(true, '->previousAll() throws an \\InvalidArgumentException if the node list is empty');
  }
}