Skip to content

Commit 4fdc37b

Browse files
committed
Skip head tests
1 parent 5959b25 commit 4fdc37b

1 file changed

Lines changed: 18 additions & 23 deletions

File tree

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

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ class Tests_HtmlApi_WpHtmlProcessorHtml5lib extends WP_UnitTestCase {
4747
* @param string $result Tree structure of parsed HTML.
4848
*/
4949
public function test_external_html5lib( $fragment_context, $html, $result ) {
50-
$processed_tree = self::build_html5_treelike_string( $fragment_context, $html );
50+
if ( self::SKIP_HEAD_TESTS ) {
51+
$html_start = "<html>\n <head>\n <body>\n";
52+
if (
53+
strlen( $result ) < strlen( $html_start ) ||
54+
substr( $result, 0, strlen( $html_start ) ) !== $html_start
55+
) {
56+
$this->markTestSkipped( 'Skip test with expected content in <head> (unsupported).' );
57+
}
58+
}
5159

5260
if ( array_key_exists( $this->dataName(), self::SKIP_TESTS ) ) {
5361
$this->markTestSkipped( self::SKIP_TESTS[ $this->dataName() ] );
5462
}
5563

64+
$processed_tree = self::build_html5_treelike_string( $fragment_context, $html );
65+
5666
if ( null === $processed_tree ) {
5767
$this->markTestIncomplete( 'Test includes unsupported markup.' );
5868
}
@@ -161,28 +171,13 @@ public static function parse_html5_dat_testfile( $filename ) {
161171
if ( "#data\n" === $line ) {
162172
// Yield when switching from a previous state.
163173
if ( $state ) {
164-
$yield_test = true;
165-
166-
if ( self::SKIP_HEAD_TESTS ) {
167-
$html_start = "<html>\n <head>\n <body>\n";
168-
169-
if (
170-
strlen( $test_dom ) < strlen( $html_start ) ||
171-
substr( $test_dom, 0, strlen( $html_start ) ) !== $html_start
172-
) {
173-
$yield_test = false;
174-
}
175-
}
176-
177-
if ( $yield_test ) {
178-
yield array(
179-
$test_line_number,
180-
$test_context_element,
181-
// Remove the trailing newline
182-
substr( $test_html, 0, -1 ),
183-
$test_dom,
184-
);
185-
}
174+
yield array(
175+
$test_line_number,
176+
$test_context_element,
177+
// Remove the trailing newline
178+
substr( $test_html, 0, -1 ),
179+
$test_dom,
180+
);
186181
}
187182

188183
// Finish previous test.

0 commit comments

Comments
 (0)