@@ -28,7 +28,7 @@ public function test_select_miss() {
2828 public function test_select ( string $ html , string $ selector ) {
2929 $ processor = WP_HTML_Processor::create_full_parser ( $ html );
3030 $ this ->assertTrue ( $ processor ->select ( $ selector ) );
31- $ this ->assertTrue ( $ processor ->get_attribute ( 'target ' ) );
31+ $ this ->assertTrue ( $ processor ->get_attribute ( 'match ' ) );
3232 }
3333
3434 /**
@@ -38,18 +38,31 @@ public function test_select( string $html, string $selector ) {
3838 */
3939 public static function data_selectors (): array {
4040 return array (
41- 'simple type ' => array ( '<div target > ' , 'div ' ),
42- 'any type ' => array ( '<html target > ' , '* ' ),
43- 'simple class ' => array ( '<div class="x" target > ' , '.x ' ),
44- 'simple id ' => array ( '<div id="x" target > ' , '#x ' ),
45- 'simple attribute ' => array ( '<div att target > ' , '[att] ' ),
46- 'attribute value ' => array ( '<div att="val" target > ' , '[att=val] ' ),
47- 'attribute quoted value ' => array ( '<div att="::" target > ' , '[att="::"] ' ),
48- 'complex any descendant ' => array ( '<section><div target > ' , 'section * ' ),
49- 'complex any child ' => array ( '<section><div target > ' , 'section > * ' ),
41+ 'simple type ' => array ( '<div match > ' , 'div ' ),
42+ 'any type ' => array ( '<html match > ' , '* ' ),
43+ 'simple class ' => array ( '<div class="x" match > ' , '.x ' ),
44+ 'simple id ' => array ( '<div id="x" match > ' , '#x ' ),
45+ 'simple attribute ' => array ( '<div att match > ' , '[att] ' ),
46+ 'attribute value ' => array ( '<div att="val" match > ' , '[att=val] ' ),
47+ 'attribute quoted value ' => array ( '<div att="::" match > ' , '[att="::"] ' ),
48+ 'complex any descendant ' => array ( '<section><div match > ' , 'section * ' ),
49+ 'complex any child ' => array ( '<section><div match > ' , 'section > * ' ),
5050
51- 'list ' => array ( '<div><p target > ' , 'a, p ' ),
52- 'compound ' => array ( '<div att><section att="foo bar" target > ' , 'section[att~="bar"] ' ),
51+ 'list ' => array ( '<div><p match > ' , 'a, p ' ),
52+ 'compound ' => array ( '<div att><section att="foo bar" match > ' , 'section[att~="bar"] ' ),
5353 );
5454 }
55+
56+ /**
57+ * @ticket TBD
58+ */
59+ public function test_select_all () {
60+ $ processor = WP_HTML_Processor::create_full_parser ( '<div match><p class="x" match><svg><rect match/></svg><i id="y" match></i> ' );
61+ $ count = 0 ;
62+ foreach ( $ processor ->select_all ( 'div, .x, svg>rect, #y ' ) as $ _ ) {
63+ ++$ count ;
64+ $ this ->assertTrue ( $ processor ->get_attribute ( 'match ' ) );
65+ }
66+ $ this ->assertSame ( 4 , $ count );
67+ }
5568}
0 commit comments