tests: Move assertHTMLEquals to the test case trait
This allows accessing it in both integration and unit tests. Bug: T310514 Change-Id: I5c97364cbdc81fe67f156cffb04b252af7ccf6ff
This commit is contained in:
parent
a7b9466313
commit
3fd374e974
2 changed files with 20 additions and 19 deletions
|
|
@ -2175,25 +2175,6 @@ abstract class MediaWikiIntegrationTestCase 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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for eliminating all string keys from an array.
|
||||
* Useful to turn a database result row as returned by fetchRow() into
|
||||
|
|
|
|||
|
|
@ -391,4 +391,24 @@ trait MediaWikiTestCaseTrait {
|
|||
$this->assertStatusOK( $status, $message );
|
||||
$this->assertStatusMessage( $messageKey, $status, $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @since 1.39 available in MediaWikiUnitTestCase
|
||||
*
|
||||
* @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 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue