mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Use FormatJson helper for outputting pretty JSON for tests
Identical output, fewer constants and regexps. Change-Id: I50fd536d9122ac91a7261660405219e19d974047
This commit is contained in:
parent
50874ab4b7
commit
465168112c
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace MediaWiki\Extension\DiscussionTools\Tests;
|
||||
|
||||
use FormatJson;
|
||||
use MediaWiki\Extension\DiscussionTools\CommentParser;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Parsoid\DOM\Document;
|
||||
|
@ -77,9 +78,7 @@ trait TestUtils {
|
|||
* @param array $data
|
||||
*/
|
||||
protected static function overwriteJsonFile( string $relativePath, array $data ): void {
|
||||
$json = json_encode( $data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
|
||||
// Tabs instead of 4 spaces
|
||||
$json = preg_replace( '/(?:\G|^) {4}/m', "\t", $json );
|
||||
$json = FormatJson::encode( $data, "\t", FormatJson::ALL_OK );
|
||||
file_put_contents( __DIR__ . '/' . $relativePath, $json . "\n" );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue