Changeset View
Changeset View
Standalone View
Standalone View
src/parser/html/__tests__/PhutilHTMLParserTestCase.php
| Show All 36 Lines | foreach ($tests as $test) { | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| $expect, | $expect, | ||||
| $list, | $list, | ||||
| pht('DOM tree for "%s".', $test)); | pht('DOM tree for "%s".', $test)); | ||||
| } | } | ||||
| } | } | ||||
| public function testSelectChildrenWithTags() { | |||||
| $input = '<a></a><b></b><a /><c /><a /><x></x><y /><a /><d>x</d><a /><e>'; | |||||
| $document = id(new PhutilHTMLParser()) | |||||
| ->parseDocument($input); | |||||
| $children = $document->selectChildrenWithTags(array('a')); | |||||
| $list = array(); | |||||
| foreach ($children as $child) { | |||||
| $list[] = $child->toDictionary(); | |||||
| } | |||||
| $this->assertEqual( | |||||
| array( | |||||
| array( | |||||
| 'tag' => 'a', | |||||
| 'attributes' => array(), | |||||
| 'children' => array(), | |||||
| ), | |||||
| array( | |||||
| 'content' => '<b></b>', | |||||
| ), | |||||
| array( | |||||
| 'tag' => 'a', | |||||
| 'attributes' => array(), | |||||
| 'children' => array(), | |||||
| ), | |||||
| array( | |||||
| 'content' => '<c />', | |||||
| ), | |||||
| array( | |||||
| 'tag' => 'a', | |||||
| 'attributes' => array(), | |||||
| 'children' => array(), | |||||
| ), | |||||
| array( | |||||
| 'content' => '<x></x><y />', | |||||
| ), | |||||
| array( | |||||
| 'tag' => 'a', | |||||
| 'attributes' => array(), | |||||
| 'children' => array(), | |||||
| ), | |||||
| array( | |||||
| 'content' => '<d>x</d>', | |||||
| ), | |||||
| array( | |||||
| 'tag' => 'a', | |||||
| 'attributes' => array(), | |||||
| 'children' => array(), | |||||
| ), | |||||
| array( | |||||
| 'content' => '<e>', | |||||
| ), | |||||
| ), | |||||
| $list, | |||||
| pht('Child selection of: %s.', $input)); | |||||
| } | |||||
| } | } | ||||