Changeset 57316 for trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
- Timestamp:
- 01/19/2024 09:40:01 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
r57314 r57316 134 134 135 135 /** 136 * Ensure non-nesting tags do not nest. 137 * 138 * @ticket 60283 139 * 140 * @covers WP_HTML_Processor::step_in_body 141 * @covers WP_HTML_Processor::is_void 142 * 143 * @dataProvider data_void_tags 144 * 145 * @param string $tag_name Name of void tag under test. 146 */ 147 public function test_cannot_nest_void_tags( $tag_name ) { 148 $processor = WP_HTML_Processor::create_fragment( "<{$tag_name}><div>" ); 149 150 /* 151 * This HTML represents the same as the following HTML, 152 * assuming that it were provided `<img>` as the tag: 153 * 154 * <html> 155 * <body> 156 * <img> 157 * <div></div> 158 * </body> 159 * </html> 160 */ 161 162 $found_tag = $processor->next_tag(); 163 164 if ( WP_HTML_Processor::ERROR_UNSUPPORTED === $processor->get_last_error() ) { 165 $this->markTestSkipped( "Tag {$tag_name} is not supported." ); 166 } 167 168 $this->assertTrue( 169 $found_tag, 170 "Could not find first {$tag_name}." 171 ); 172 173 $this->assertSame( 174 array( 'HTML', 'BODY', $tag_name ), 175 $processor->get_breadcrumbs(), 176 'Found incorrect nesting of first element.' 177 ); 178 179 $this->assertTrue( 180 $processor->next_tag(), 181 'Should have found the DIV as the second tag.' 182 ); 183 184 $this->assertSame( 185 array( 'HTML', 'BODY', 'DIV' ), 186 $processor->get_breadcrumbs(), 187 "DIV should have been a sibling of the {$tag_name}." 188 ); 189 } 190 191 /** 192 * Data provider. 193 * 194 * @return array[] 195 */ 196 public function data_void_tags() { 197 return array( 198 'AREA' => array( 'AREA' ), 199 'BASE' => array( 'BASE' ), 200 'BR' => array( 'BR' ), 201 'COL' => array( 'COL' ), 202 'EMBED' => array( 'EMBED' ), 203 'HR' => array( 'HR' ), 204 'IMG' => array( 'IMG' ), 205 'INPUT' => array( 'INPUT' ), 206 'KEYGEN' => array( 'KEYGEN' ), 207 'LINK' => array( 'LINK' ), 208 'META' => array( 'META' ), 209 'SOURCE' => array( 'SOURCE' ), 210 'TRACK' => array( 'TRACK' ), 211 'WBR' => array( 'WBR' ), 212 ); 213 } 214 215 /** 136 216 * Ensures that special handling of unsupported tags is cleaned up 137 217 * as handling is implemented. Otherwise there's risk of leaving special … … 160 240 return array( 161 241 'APPLET' => array( 'APPLET' ), 162 'AREA' => array( 'AREA' ),163 242 'BASE' => array( 'BASE' ), 164 243 'BASEFONT' => array( 'BASEFONT' ), 165 244 'BGSOUND' => array( 'BGSOUND' ), 166 245 'BODY' => array( 'BODY' ), 167 'BR' => array( 'BR' ),168 246 'CAPTION' => array( 'CAPTION' ), 169 247 'COL' => array( 'COL' ), 170 248 'COLGROUP' => array( 'COLGROUP' ), 171 'EMBED' => array( 'EMBED' ),172 249 'FORM' => array( 'FORM' ), 173 250 'FRAME' => array( 'FRAME' ), … … 177 254 'IFRAME' => array( 'IFRAME' ), 178 255 'INPUT' => array( 'INPUT' ), 179 'KEYGEN' => array( 'KEYGEN' ),180 256 'LINK' => array( 'LINK' ), 181 257 'LISTING' => array( 'LISTING' ), … … 214 290 'TR' => array( 'TR' ), 215 291 'TRACK' => array( 'TRACK' ), 216 'WBR' => array( 'WBR' ),217 292 'XMP' => array( 'XMP' ), 218 293 );
Note: See TracChangeset
for help on using the changeset viewer.