From: jenkins-bot
Date: Thu, 21 Jul 2016 17:27:59 +0000 (+0000)
Subject: Merge "Enable additional balancer tests (those starting with ``)"
X-Git-Tag: 1.31.0-rc.0~6312
X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=29d3feb1d0278cc383f21dac291c11d873c4316a;hp=-c;p=lhc%2Fweb%2Fwiklou.git
Merge "Enable additional balancer tests (those starting with ``)"
---
29d3feb1d0278cc383f21dac291c11d873c4316a
diff --combined tests/phpunit/includes/tidy/BalancerTest.php
index f285e04103,740ddb9d43..f69ecafd5c
--- a/tests/phpunit/includes/tidy/BalancerTest.php
+++ b/tests/phpunit/includes/tidy/BalancerTest.php
@@@ -20,7 -20,14 +20,7 @@@ class BalancerTest extends MediaWikiTes
}
/**
- * Anything cleanup you need to do should go here.
- */
- protected function tearDown() {
- parent::tearDown();
- }
-
- /**
- * @covers Balancer::balance
+ * @covers MediaWiki\Tidy\Balancer::balance
* @dataProvider provideBalancerTests
*/
public function testBalancer( $description, $input, $expected ) {
@@@ -41,15 -48,16 +41,16 @@@
// for providers, and filter out HTML constructs which
// the balancer doesn't support.
$tests = [];
- $start = '';
- $end = '';
+ $okre = "~ \A
+ (?i:)?
+
+ .*
+
+ \z ~xs";
foreach ( $json as $filename => $cases ) {
foreach ( $cases as $case ) {
$html = $case['document']['html'];
- if (
- substr( $html, 0, strlen( $start ) ) !== $start ||
- substr( $html, -strlen( $end ) ) !== $end
- ) {
+ if ( !preg_match( $okre, $html ) ) {
// Skip tests which involve stuff in the or
// weird doctypes.
continue;
@@@ -63,6 -71,8 +64,8 @@@
$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'] ) &&
@@@ -76,11 -86,17 +79,17 @@@
// Skip tests involving quoting.
continue;
}
- if ( stripos( $case['data'], '' ) === false
+ ) {
+ // Skip tests involving unusual doctypes.
continue;
}
- if ( preg_match( ',?(html|head|body|frame|plaintext)>| ~xi";
+ if ( preg_match( $literalre, $case['data'] ) ) {
// Skip tests involving some literal tags, which are
// unsupported but don't show up in the expected output.
continue;
@@@ -112,7 -128,8 +121,8 @@@
isset( $case['document']['props']['tagWithLt'] ) ||
isset( $case['document']['props']['attrWithFunnyChar'] ) ||
preg_match( ':^()$:', $case['data'] ) ||
- preg_match( ':
:', $case['data'] )
+ preg_match( '::', $case['data'] ) ||
+ preg_match( ':|:', $case['data'] )
) {
// Skip tests with funny tag or attribute names,
// which are really tests of the HTML tokenizer, not
@@@ -120,7 -137,7 +130,7 @@@
continue;
}
if (
- stripos( $case['data'], 'encoding=" text/html "' ) !== false
+ preg_match( ':encoding=" text/html "|type=" hidden":', $case['data'] )
) {
// The Sanitizer normalizes whitespace in attribute
// values, which makes this test case invalid.
@@@ -130,9 -147,12 +140,12 @@@
// Skip tests with ASCII null, etc.
continue;
}
+ $data = preg_replace(
+ '~~i', '', $case['data']
+ );
$tests[] = [
$filename, # use better description?
- $case['data'],
+ $data,
$html
];
}