Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/169695
Change subject: Add test for wikitext-html-wikitext roundtrip
......................................................................
Add test for wikitext-html-wikitext roundtrip
Change-Id: Iaaa450bab2c48e2c9a152c6d1e08ef0d25eb459b
---
M includes/Parsoid/Utils.php
M tests/phpunit/Parsoid/UtilsTest.php
2 files changed, 42 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/95/169695/1
diff --git a/includes/Parsoid/Utils.php b/includes/Parsoid/Utils.php
index b36235b..08a550b 100644
--- a/includes/Parsoid/Utils.php
+++ b/includes/Parsoid/Utils.php
@@ -172,9 +172,9 @@
$wgVisualEditorParsoidURL,
$wgVisualEditorParsoidPrefix, $wgVisualEditorParsoidTimeout;
return array(
- $wgFlowParsoidURL ? $wgFlowParsoidURL :
$wgVisualEditorParsoidURL,
- $wgFlowParsoidPrefix ? $wgFlowParsoidPrefix :
$wgVisualEditorParsoidPrefix,
- $wgFlowParsoidTimeout ? $wgFlowParsoidTimeout :
$wgVisualEditorParsoidTimeout,
+ $wgFlowParsoidURL ?: $wgVisualEditorParsoidURL,
+ $wgFlowParsoidPrefix ?: $wgVisualEditorParsoidPrefix,
+ $wgFlowParsoidTimeout ?: $wgVisualEditorParsoidTimeout,
);
}
diff --git a/tests/phpunit/Parsoid/UtilsTest.php
b/tests/phpunit/Parsoid/UtilsTest.php
index 8a4e4a9..4b16e0a 100644
--- a/tests/phpunit/Parsoid/UtilsTest.php
+++ b/tests/phpunit/Parsoid/UtilsTest.php
@@ -70,4 +70,43 @@
$this->assertEquals( $expect, $result, $message );
}
}
+
+ static public function wikitextRoundtripProvider() {
+ return array(
+ array(
+ 'italic text',
+ // text & expect
+ "''italic text''",
+ // title
+ Title::newMainPage(),
+ ),
+ array(
+ 'bold text',
+ // text & expect
+ "'''bold text'''",
+ // title
+ Title::newMainPage(),
+ ),
+ );
+ }
+
+ /**
+ * Test full roundtrip (wikitext -> html -> wikitext)
+ *
+ * It doesn't make sense to test only a specific path, since Parsoid's
HTML
+ * may change beyond our control & it doesn't really matter to us what
+ * exactly the HTML looks like, as long as Parsoid is able to
understand it.
+ *
+ * @dataProvider wikitextRoundtripProvider
+ */
+ public function testwikitextRoundtrip( $message, $expect, Title $title
) {
+ // Check for Parsoid
+ try {
+ $html = Utils::convert( 'wikitext', 'html', $expect,
$title );
+ $wikitext = Utils::convert( 'html', 'wikitext', $html,
$title );
+ $this->assertEquals( $expect, trim( $wikitext ),
$message );
+ } catch ( WikitextException $excep ) {
+ $this->markTestSkipped( 'Parsoid not enabled' );
+ }
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/169695
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaaa450bab2c48e2c9a152c6d1e08ef0d25eb459b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits