From: Antoine Musso Date: Mon, 3 Sep 2012 08:46:07 +0000 (+0200) Subject: test: new assertHTMLEquals() X-Git-Tag: 1.31.0-rc.0~22470^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=19d5ab2e8a0f2255265c82290dd8041d06633ef7;p=lhc%2Fweb%2Fwiklou.git test: new assertHTMLEquals() Very trivial helper to compare HTML content. The method just add a newline after each closing angle and then call assertEquals(). Change-Id: I5e6daa916a4fb452824616fa3c8a87bdb8038e8c --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 49c2a70109..bfad334e65 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -441,6 +441,25 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { ); } + /** + * Put each HTML element on its own line and then equals() the results + * + * Use for nicely formatting of PHPUnit diff output when comparing very + * simple HTML + * + * @since 1.20 + * + * @param String $expected HTML on oneline + * @param String $actual HTML on oneline + * @param String $msg Optional message + */ + protected function assertHTMLEquals( $expected, $actual, $msg='' ) { + $expected = str_replace( '>', ">\n", $expected ); + $actual = str_replace( '>', ">\n", $actual ); + + $this->assertEquals( $expected, $actual, $msg ); + } + /** * Does an associative sort that works for objects. *