From dba0522f702b08395f23cd36c356be8226108782 Mon Sep 17 00:00:00 2001 From: addshore Date: Sun, 17 Aug 2014 22:38:07 +0100 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiTestCase.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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); + } } -- 2.20.1