Add tests for DiffEngine tooltips
authorWMDE-Fisch <christoph.jauera@wikimedia.de>
Wed, 22 Nov 2017 13:28:52 +0000 (14:28 +0100)
committerWMDE-Fisch <christoph.jauera@wikimedia.de>
Wed, 22 Nov 2017 14:24:20 +0000 (15:24 +0100)
Change-Id: I8e6560efc35a6bd875f96edb9b59c9961b81a956

tests/phpunit/includes/diff/DifferenceEngineTest.php

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 ) );
+       }
+
 }