From 19d5ab2e8a0f2255265c82290dd8041d06633ef7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 3 Sep 2012 10:46:07 +0200 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiTestCase.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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. * -- 2.20.1