false, /* not strict */ 'allowedHtmlElements' => null, /* no sanitization */ 'tidyCompat' => $useTidy, /* standard parser */ 'allowComments' => true, /* comment parsing */ ] ); $output = $balancer->balance( $input ); // Ignore self-closing tags $output = preg_replace( '/\s*\/>/', '>', $output ); $this->assertEquals( $expected, $output, $description ); } public static function provideBalancerTests() { // Get the tests from html5lib-tests.json $json = json_decode( file_get_contents( __DIR__ . '/html5lib-tests.json' ), true ); // Munge this slightly into the format phpunit expects // for providers, and filter out HTML constructs which // the balancer doesn't support. $tests = []; $okre = "~ \A (?i:)? .* \z ~xs"; foreach ( $json as $filename => $cases ) { foreach ( $cases as $case ) { $html = $case['document']['html']; if ( !preg_match( $okre, $html ) ) { // Skip tests which involve stuff in the or // weird doctypes. continue; } // We used to do this: // $html = substr( $html, strlen( $start ), -strlen( $end ) ); // But now we use a different field in the test case, // which reports how domino would parse this case in a // no-quirks context. (The original test case may // have had a different context, or relied on quirks mode.) $html = $case['document']['noQuirksBodyHtml']; // Normalize case of SVG attributes. $html = str_replace( 'foreignObject', 'foreignobject', $html ); // Normalize case of MathML attributes. $html = str_replace( 'definitionURL', 'definitionurl', $html ); if ( isset( $case['document']['props']['comment'] ) && preg_match( ',