Amire80 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/92172
Change subject: WIP: TranslationAid tests
......................................................................
WIP: TranslationAid tests
Started with Niklas in SF. Committing as WIP.
Change-Id: I20decb8398f3b65ad38f05eea246b46af7550280
---
A tests/TranslationAidTest.php
1 file changed, 75 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/72/92172/1
diff --git a/tests/TranslationAidTest.php b/tests/TranslationAidTest.php
new file mode 100644
index 0000000..2d8a0c4
--- /dev/null
+++ b/tests/TranslationAidTest.php
@@ -0,0 +1,75 @@
+<?php
+/**
+ * Tests for fuzzy flag change on edits.
+ * @author Niklas Laxström
+ * @file
+ * @copyright Copyright © 2012-2013, Niklas Laxström
+ * @license GPL-2.0+
+ */
+
+/**
+ * Tests for fuzzy flag change on edits.
+ * @group Database
+ * @group medium
+ */
+class TranslationAidTest extends MediaWikiTestCase {
+ protected function setUp() {
+ parent::setUp();
+
+ global $wgHooks;
+ $this->setMwGlobals( array(
+ 'wgHooks' => $wgHooks,
+ 'wgTranslateCC' => array(),
+ 'wgTranslateMessageIndex' => array(
'DatabaseMessageIndex' ),
+ 'wgTranslateWorkflowStates' => false,
+ 'wgTranslateGroupFiles' => array(),
+ 'wgTranslateTranslationServices' => array(),
+ ) );
+ $wgHooks['TranslatePostInitGroups'] = array( array( $this,
'getTestGroups' ) );
+ MessageGroups::clearCache();
+ MessageIndexRebuildJob::newJob()->run();
+ }
+
+ public function getTestGroups( &$list ) {
+ $messages = array( 'ugakey' => '$1 of $2', );
+ $list['test-group'] = new MockWikiMessageGroup( 'test-group',
$messages );
+
+ return false;
+ }
+
+ public function testParsing() {
+ $title = Title::newFromText( 'MediaWiki:Ugakey/nl' );
+ $page = WikiPage::factory( $title );
+ $status = $page->doEdit( '$1 van $2', __METHOD__ );
+ $value = $status->getValue();
+ /**
+ * @var Revision $rev
+ */
+ $rev = $value['revision'];
+ $revision = $rev->getId();
+
+ $dbw = wfGetDB( DB_MASTER );
+ $conds = array(
+ 'rt_page' => $title->getArticleID(),
+ 'rt_type' => RevTag::getType( 'fuzzy' ),
+ 'rt_revision' => $revision
+ );
+
+ $index = array_keys( $conds );
+ $dbw->replace( 'revtag', array( $index ), $conds, __METHOD__ );
+
+ $handle = new MessageHandle( $title );
+ $this->assertTrue( $handle->isValid(), 'Message is known' );
+ $this->assertTrue( $handle->isFuzzy(), 'Message is fuzzy after
database fuzzying' );
+ // Update the translation without the fuzzy string
+ $page->doEdit( '$1 van $2', __METHOD__ );
+ $this->assertFalse( $handle->isFuzzy(), 'Message is unfuzzy
after edit' );
+
+ $page->doEdit( '!!FUZZY!!$1 van $2', __METHOD__ );
+ $this->assertTrue( $handle->isFuzzy(), 'Message is fuzzy after
manual fuzzying' );
+
+ // Update the translation without the fuzzy string
+ $page->doEdit( '$1 van $2', __METHOD__ );
+ $this->assertFalse( $handle->isFuzzy(), 'Message is unfuzzy
after edit' );
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/92172
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I20decb8398f3b65ad38f05eea246b46af7550280
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits