[DomCrawler] extract(): fix a bug when the attribute list is empty
This commit is contained in:
parent
1616d368d9
commit
028c9f2366
@ -605,7 +605,7 @@ class Crawler extends \SplObjectStorage
|
||||
}
|
||||
}
|
||||
|
||||
$data[] = $count > 1 ? $elements : $elements[0];
|
||||
$data[] = 1 === $count ? $elements[0] : $elements;
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -369,6 +369,7 @@ EOF
|
||||
|
||||
$this->assertEquals(array('One', 'Two', 'Three'), $crawler->extract('_text'), '->extract() returns an array of extracted data from the node list');
|
||||
$this->assertEquals(array(array('One', 'first'), array('Two', ''), array('Three', '')), $crawler->extract(array('_text', 'class')), '->extract() returns an array of extracted data from the node list');
|
||||
$this->assertEquals(array(array(), array(), array()), $crawler->extract(array()), '->extract() returns empty arrays if the attribute list is empty');
|
||||
|
||||
$this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty');
|
||||
}
|
||||
|
Reference in New Issue
Block a user