Changeset 55562 for trunk/tests/phpunit/tests/formatting/balanceTags.php
- Timestamp:
- 03/19/2023 12:03:30 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/balanceTags.php
r54727 r55562 8 8 class Tests_Formatting_BalanceTags extends WP_UnitTestCase { 9 9 10 public function nestable_tags() { 11 return array( 12 array( 'article' ), 13 array( 'aside' ), 14 array( 'blockquote' ), 15 array( 'details' ), 16 array( 'div' ), 17 array( 'figure' ), 18 array( 'object' ), 19 array( 'q' ), 20 array( 'section' ), 21 array( 'span' ), 22 ); 23 } 24 25 // This is a complete(?) listing of valid single/self-closing tags. 26 public function single_tags() { 27 return array( 28 array( 'area' ), 29 array( 'base' ), 30 array( 'basefont' ), 31 array( 'br' ), 32 array( 'col' ), 33 array( 'command' ), 34 array( 'embed' ), 35 array( 'frame' ), 36 array( 'hr' ), 37 array( 'img' ), 38 array( 'input' ), 39 array( 'isindex' ), 40 array( 'link' ), 41 array( 'meta' ), 42 array( 'param' ), 43 array( 'source' ), 44 array( 'track' ), 45 array( 'wbr' ), 46 ); 47 } 48 49 public function supported_traditional_tag_names() { 10 /** 11 * @ticket 47014 12 * @dataProvider data_supported_traditional_tag_names 13 */ 14 public function test_detects_traditional_tag_names( $tag ) { 15 $normalized = strtolower( $tag ); 16 17 $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) ); 18 } 19 20 public function data_supported_traditional_tag_names() { 50 21 return array( 51 22 array( 'a' ), … … 59 30 } 60 31 61 public function supported_custom_element_tag_names() { 32 /** 33 * @ticket 47014 34 * @dataProvider data_supported_custom_element_tag_names 35 */ 36 public function test_detects_supported_custom_element_tag_names( $tag ) { 37 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); 38 } 39 40 public function data_supported_custom_element_tag_names() { 62 41 return array( 63 42 array( 'custom-element' ), … … 71 50 } 72 51 73 public function invalid_tag_names() { 52 /** 53 * @ticket 47014 54 * @dataProvider data_invalid_tag_names 55 */ 56 public function test_ignores_invalid_tag_names( $input, $output ) { 57 $this->assertSame( $output, balanceTags( $input, true ) ); 58 } 59 60 public function data_invalid_tag_names() { 74 61 return array( 75 62 array( '<0-day>inside', '<0-day>inside' ), // Can't start with a number - handled by the "<3" fix. … … 79 66 80 67 /** 68 * @ticket 47014 69 * @dataProvider data_unsupported_valid_tag_names 70 */ 71 public function test_ignores_unsupported_custom_tag_names( $tag ) { 72 $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); 73 } 74 75 /** 81 76 * These are valid custom elements but we don't support them yet. 82 77 * 83 78 * @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name 84 79 */ 85 public function unsupported_valid_tag_names() {80 public function data_unsupported_valid_tag_names() { 86 81 return array( 87 82 // We don't allow ending in a dash. … … 139 134 140 135 /** 136 * @ticket 47014 137 * @dataProvider data_supported_invalid_tag_names 138 */ 139 public function test_detects_supported_invalid_tag_names( $tag ) { 140 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); 141 } 142 143 /** 141 144 * These are invalid custom elements but we support them right now in order to keep the parser simpler. 142 145 * 143 146 * @see https://w3c.github.io/webcomponents/spec/custom/#valid-custom-element-name 144 147 */ 145 public function supported_invalid_tag_names() {148 public function data_supported_invalid_tag_names() { 146 149 return array( 147 150 // Reserved names for custom elements. … … 158 161 159 162 /** 160 * @ticket 47014161 * @dataProvider supported_traditional_tag_names162 */163 public function test_detects_traditional_tag_names( $tag ) {164 $normalized = strtolower( $tag );165 166 $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) );167 }168 169 /**170 * @ticket 47014171 * @dataProvider supported_custom_element_tag_names172 */173 public function test_detects_supported_custom_element_tag_names( $tag ) {174 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );175 }176 177 /**178 * @ticket 47014179 * @dataProvider invalid_tag_names180 */181 public function test_ignores_invalid_tag_names( $input, $output ) {182 $this->assertSame( $output, balanceTags( $input, true ) );183 }184 185 /**186 * @ticket 47014187 * @dataProvider unsupported_valid_tag_names188 */189 public function test_ignores_unsupported_custom_tag_names( $tag ) {190 $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) );191 }192 193 /**194 * @ticket 47014195 * @dataProvider supported_invalid_tag_names196 */197 public function test_detects_supported_invalid_tag_names( $tag ) {198 $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) );199 }200 201 /**202 163 * If a recognized valid single tag appears unclosed, it should get self-closed 203 164 * 204 165 * @ticket 1597 205 * @dataProvider single_tags166 * @dataProvider data_single_tags 206 167 */ 207 168 public function test_selfcloses_unclosed_known_single_tags( $tag ) { … … 214 175 * 215 176 * @ticket 1597 216 * @dataProvider single_tags177 * @dataProvider data_single_tags 217 178 */ 218 179 public function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { 219 180 $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); 181 } 182 183 // This is a complete(?) listing of valid single/self-closing tags. 184 public function data_single_tags() { 185 return array( 186 array( 'area' ), 187 array( 'base' ), 188 array( 'basefont' ), 189 array( 'br' ), 190 array( 'col' ), 191 array( 'command' ), 192 array( 'embed' ), 193 array( 'frame' ), 194 array( 'hr' ), 195 array( 'img' ), 196 array( 'input' ), 197 array( 'isindex' ), 198 array( 'link' ), 199 array( 'meta' ), 200 array( 'param' ), 201 array( 'source' ), 202 array( 'track' ), 203 array( 'wbr' ), 204 ); 220 205 } 221 206 … … 275 260 276 261 /** 277 * @dataProvider nestable_tags262 * @dataProvider data_nestable_tags 278 263 */ 279 264 public function test_balances_nestable_tags( $tag ) { … … 292 277 $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); 293 278 } 279 } 280 281 public function data_nestable_tags() { 282 return array( 283 array( 'article' ), 284 array( 'aside' ), 285 array( 'blockquote' ), 286 array( 'details' ), 287 array( 'div' ), 288 array( 'figure' ), 289 array( 'object' ), 290 array( 'q' ), 291 array( 'section' ), 292 array( 'span' ), 293 ); 294 294 } 295 295
Note: See TracChangeset
for help on using the changeset viewer.