Merge "Add missing message dependency to oojs-ui-widgets"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 22 Nov 2017 16:35:56 +0000 (16:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 22 Nov 2017 16:35:56 +0000 (16:35 +0000)
includes/diff/DifferenceEngine.php
tests/phpunit/includes/diff/DifferenceEngineTest.php

index 03f7212..51b9f15 100644 (file)
@@ -1127,7 +1127,7 @@ class DifferenceEngine extends ContextSource {
         */
        private function addLocalisedTitleTooltips( $text ) {
                return preg_replace_callback(
-                       '/class="mw-diff-movedpara-(left|old)"/',
+                       '/class="mw-diff-movedpara-(left|right)"/',
                        [ $this, 'addLocalisedTitleTooltipsCb' ],
                        $text
                );
index 3a8f4db..57aeb20 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\TestingAccessWrapper;
+
 /**
  * @covers DifferenceEngine
  *
@@ -117,4 +119,30 @@ class DifferenceEngineTest extends MediaWikiTestCase {
                $this->assertEquals( $revs[2], $diffEngine->getNewid(), 'diff get new id' );
        }
 
+       public function provideLocaliseTitleTooltipsTestData() {
+               return [
+                       'moved paragraph left shoud get new location title' => [
+                               '<a class="mw-diff-movedpara-left">⚫</a>',
+                               '<a class="mw-diff-movedpara-left" title="(diff-paragraph-moved-tonew)">⚫</a>',
+                       ],
+                       'moved paragraph right shoud get old location title' => [
+                               '<a class="mw-diff-movedpara-right">⚫</a>',
+                               '<a class="mw-diff-movedpara-right" title="(diff-paragraph-moved-toold)">⚫</a>',
+                       ],
+                       'nothing changed when key not hit' => [
+                               '<a class="mw-diff-movedpara-rightis">⚫</a>',
+                               '<a class="mw-diff-movedpara-rightis">⚫</a>',
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideLocaliseTitleTooltipsTestData
+        */
+       public function testAddLocalisedTitleTooltips( $input, $expected ) {
+               $this->setContentLang( 'qqx' );
+               $diffEngine = TestingAccessWrapper::newFromObject( new DifferenceEngine() );
+               $this->assertEquals( $expected, $diffEngine->addLocalisedTitleTooltips( $input ) );
+       }
+
 }