From: Marius Hoch Date: Thu, 23 Jan 2014 20:02:34 +0000 (+0100) Subject: Ignore certain tidy warnings in assertValidHtmlDocument X-Git-Tag: 1.31.0-rc.0~17118 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=5785c77a00e7c54a2b9627d7cc58152ed8c7b002;p=lhc%2Fweb%2Fwiklou.git Ignore certain tidy warnings in assertValidHtmlDocument Those aren't really useful, especially as tidy often cries about parameters missing which have been deprecated since HTML 4, so that these warnings have no value for us. Change-Id: Ic27c597aa988079ed08e152861bf1dee9581b829 --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 95b50474ad..87e214cb9e 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1003,7 +1003,18 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->markTestSkipped( 'Tidy extension not installed' ); } - $ok = MWTidy::checkErrors( $html, $errors ); - $this->assertTrue( $ok, 'HTML validation errors: ' . $errors ); + $errorBuffer = ''; + MWTidy::checkErrors( $html, $errorBuffer ); + $allErrors = preg_split( '/[\r\n]+/', $errorBuffer ); + + // Filter Tidy warnings which aren't useful for us. + // Tidy eg. often cries about parameters missing which have actually + // been deprecated since HTML4, thus we should not care about them. + $errors = preg_grep( + '/^(.*Warning: (trimming empty|.* lacks ".*?" attribute).*|\s*)$/m', + $allErrors, PREG_GREP_INVERT + ); + + $this->assertEmpty( $errors, implode( "\n", $errors ) ); } }