From: addshore Date: Sun, 17 Aug 2014 21:38:07 +0000 (+0100) Subject: Override phpunit assertTag method to stop errors X-Git-Tag: 1.31.0-rc.0~14401 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=commitdiff_plain;h=dba0522f702b08395f23cd36c356be8226108782;p=lhc%2Fweb%2Fwiklou.git Override phpunit assertTag method to stop errors This method throws a deperecation error in phpunit that we dont want to see (and dont want to break travis tests). Nothing this method uses is beign deprecated thus we can override the method and not need to worry about the error or it vanishing in the future! Bug: 69505 Change-Id: I0eb63be390b4fdf416635dd8e8a2ad94615e6a47 --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 1fbc7a2a63..873d979163 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1109,4 +1109,24 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->assertEmpty( $errors, implode( "\n", $errors ) ); } + + /** + * Note: we are overriding this method to remove the deprecated error + * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=69505 + * @see https://github.com/sebastianbergmann/phpunit/issues/1292 + * + * @param array $matcher + * @param string $actual + * @param string $message + * @param bool $isHtml + */ + public static function assertTag($matcher, $actual, $message = '', $isHtml = true) { + //trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED); + + $dom = PHPUnit_Util_XML::load($actual, $isHtml); + $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); + $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; + + self::assertTrue($matched, $message); + } }