Skip to content

Commit 5b434ef

Browse files
committed
Avoid running tests that expect anything in <head>
1 parent 4319591 commit 5b434ef

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
*/
1515
class Tests_HtmlApi_WpHtmlProcessorHtml5lib extends WP_UnitTestCase {
1616

17+
/**
18+
* The HTML Processor only accepts HTML in document <body>.
19+
* Do not run tests that look for anything in document `head`.
20+
*/
21+
const SKIP_HEAD_TESTS = true;
22+
1723
const SKIP_TESTS = array(
1824
'adoption01/case10 - line 159' => 'Unimplemented: Reconstruction of active formatting elements.',
1925
'adoption01/case17 - line 318' => 'Unimplemented: Reconstruction of active formatting elements.',
@@ -33,8 +39,6 @@ class Tests_HtmlApi_WpHtmlProcessorHtml5lib extends WP_UnitTestCase {
3339
* Verify the parsing results of the HTML Processor against the
3440
* test cases in the Html5lib tests project.
3541
*
36-
* @ticket {TICKET_NUMBER}
37-
*
3842
* @dataProvider data_external_html5lib_tests
3943
*
4044
* @param string $fragment_context Context element in which to parse HTML, such as BODY or SVG.
@@ -88,7 +92,6 @@ public function data_external_html5lib_tests() {
8892
closedir( $handle );
8993
}
9094

91-
9295
/**
9396
* Generates the tree-like structure represented in the Html5lib tests.
9497
*
@@ -153,7 +156,22 @@ public static function parse_html5_dat_testfile( $filename ) {
153156
if ( "#data\n" === $line ) {
154157
// Yield when switching from a previous state.
155158
if ( $state ) {
156-
yield array( $test_line_number, $test_context_element, $test_html, $test_dom );
159+
$yield_test = true;
160+
161+
if ( self::SKIP_HEAD_TESTS ) {
162+
$html_start = "<html>\n <head>\n <body>\n";
163+
164+
if (
165+
strlen( $test_dom ) < strlen( $html_start ) ||
166+
substr( $test_dom, 0, strlen( $html_start ) ) !== $html_start
167+
) {
168+
$yield_test = false;
169+
}
170+
}
171+
172+
if ( $yield_test ) {
173+
yield array( $test_line_number, $test_context_element, $test_html, $test_dom );
174+
}
157175
}
158176

159177
// Finish previous test.

0 commit comments

Comments
 (0)