jenkins-bot has submitted this change and it was merged.
Change subject: Test case for redlink handling
......................................................................
Test case for redlink handling
Change-Id: I7546e344d9d5b7844678c75ee891e29e76a305d7
---
M includes/ParsoidUtils.php
A tests/TemplatingTest.php
2 files changed, 79 insertions(+), 1 deletion(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/ParsoidUtils.php b/includes/ParsoidUtils.php
index 9e2bea9..ecab337 100644
--- a/includes/ParsoidUtils.php
+++ b/includes/ParsoidUtils.php
@@ -195,7 +195,7 @@
);
if ( $errors ) {
throw new \MWException(
- implode( "\n", array_map( $errors, function(
$error ) { return $error->message; } ) )
+ implode( "\n", array_map( function( $error ) {
return $error->message; }, $errors ) )
);
}
diff --git a/tests/TemplatingTest.php b/tests/TemplatingTest.php
new file mode 100644
index 0000000..edc213e
--- /dev/null
+++ b/tests/TemplatingTest.php
@@ -0,0 +1,78 @@
+<?php
+
+namespace Flow;
+
+use Title;
+
+class TemplatingTest extends \MediaWikiTestCase {
+
+ // Default values for PostRevision::newFromRow to work
+ static protected $postRow = array(
+ 'rev_id' => null,
+ 'rev_user_id' => null,
+ 'rev_user_text' => null,
+ 'rev_parent_id' => null,
+ 'rev_change_type' => null,
+ 'rev_flags' => null,
+ 'rev_content' => null,
+ 'rev_mod_state' => null,
+ 'rev_mod_user_id' => null,
+ 'rev_mod_user_text' => null,
+ 'rev_mod_timestamp' => null,
+ 'tree_parent_id' => null,
+ 'tree_rev_id' => null,
+ 'tree_rev_descendant_id' => null,
+ 'tree_orig_create_time' => null,
+ 'tree_orig_user_id' => null,
+ 'tree_orig_user_text' => null,
+ );
+
+ static public function redLinkProvider() {
+ return array(
+ array(
+ 'Basic redlink application',
+ // title text from parsoid
+ 'Talk:Flow/Bugs',
+ // expect string
+ // @fixme easily breakable, depends on url order
+ htmlentities(
'Talk:Flow/Bugs&action=edit&redlink=1' ),
+ ),
+
+ array(
+ 'Subpage redlink application',
+ // title text from parsoid
+ '/SubPage',
+ // expect string
+ htmlentities(
'Main_Page/SubPage&action=edit&redlink=1' ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider redLinkProvider
+ */
+ public function testRedLinks( $message, $saHref, $expect ) {
+ // needs a page to resolve subpage links against
+ $this->setMwGlobals( 'wgTitle', Title::newMainPage() );
+
+ $parsoid = htmlentities( json_encode( array( 'sa' => array(
'href' => $saHref ) ) ) );
+ $rev = Model\PostRevision::fromStorageRow( array(
+ 'rev_content' => '<a rel="mw:WikiLink" data-parsoid="'
. $parsoid . '"></a>',
+ 'rev_flags' => 'html'
+ ) + self::$postRow );
+
+ $content = $this->mockTemplating()->getContent( $rev, 'html' );
+ $this->assertContains( $expect, $content, $message );
+ }
+
+ protected function mockTemplating() {
+ $urlGenerator = $this->getMockBuilder( 'Flow\UrlGenerator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+ $output = $this->getMockBuilder( 'OutputPage' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ return new Templating( $urlGenerator, $output );
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/100405
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7546e344d9d5b7844678c75ee891e29e76a305d7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits