mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-24 10:58:20 +00:00
tests: Fix some issues with overwriting outputs from PHP tests
Follow-up to ccd9e411d2
.
* Fix variable name in CommentTestCase::overwriteHtmlFile()
* Overwrite before assertions, because they abort execution if they fail
Change-Id: I5bba016ba93f9dd1994325ae82c3105ba11cf033
This commit is contained in:
parent
7cd370615f
commit
f0225243e0
|
@ -234,11 +234,14 @@ class CommentParserTest extends CommentTestCase {
|
|||
$thread = self::serializeComments( $thread, $body );
|
||||
$thread = json_decode( json_encode( $thread ), true );
|
||||
$processedThreads[] = $thread;
|
||||
self::assertEquals( $expected[$i], $processedThreads[$i], $name . ' section ' . $i );
|
||||
}
|
||||
|
||||
// Uncomment this to write updated content to the JSON files:
|
||||
// self::overwriteJsonFile( $expectedPath, $processedThreads );
|
||||
|
||||
foreach ( $threads as $i => $thread ) {
|
||||
self::assertEquals( $expected[$i], $processedThreads[$i], $name . ' section ' . $i );
|
||||
}
|
||||
}
|
||||
|
||||
public function provideComments() : array {
|
||||
|
|
|
@ -80,7 +80,7 @@ abstract class CommentTestCase extends MediaWikiTestCase {
|
|||
protected static function overwriteHtmlFile( string $relPath, DOMDocument $doc, string $origRelPath ) : void {
|
||||
// Do not use $doc->saveHtml(), it outputs an awful soup of HTML entities for documents with
|
||||
// non-ASCII characters
|
||||
$html = file_get_contents( __DIR__ . '/../' . $origRelativePath );
|
||||
$html = file_get_contents( __DIR__ . '/../' . $origRelPath );
|
||||
|
||||
// Replace the body tag only in full Parsoid docs
|
||||
if ( strpos( $html, '<body' ) !== false ) {
|
||||
|
@ -95,7 +95,7 @@ abstract class CommentTestCase extends MediaWikiTestCase {
|
|||
$html = DOMCompat::getInnerHTML( $doc->getElementsByTagName( 'body' )->item( 0 ) );
|
||||
}
|
||||
|
||||
file_put_contents( __DIR__ . '/../' . $relativePath, $html );
|
||||
file_put_contents( __DIR__ . '/../' . $relPath, $html );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,14 +74,14 @@ class ThreadItemTest extends CommentTestCase {
|
|||
$transcludedFrom[ $comment->getId() ] = $comment->getTranscludedFrom();
|
||||
}
|
||||
|
||||
// Uncomment this to write updated content to the JSON files:
|
||||
// self::overwriteJsonFile( $expectedPath, $transcludedFrom );
|
||||
|
||||
self::assertEquals(
|
||||
$expected,
|
||||
$transcludedFrom,
|
||||
$name
|
||||
);
|
||||
|
||||
// Uncomment this to write updated content to the JSON files:
|
||||
// self::overwriteJsonFile( $expectedPath, $transcludedFrom );
|
||||
}
|
||||
|
||||
public function provideTranscludedFrom() : array {
|
||||
|
|
Loading…
Reference in a new issue