Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/249757

Change subject: Introduce and use MediaWikiMonthNameProvider
......................................................................

Introduce and use MediaWikiMonthNameProvider

The main effect of this change is that it turns the TimeParserFactory
integration tests (integration because they are testing actual
translations from actual i18n files) into pure unit tests.

Side effect: The runtime of the TimeParserFactory tests goes down
from about 4 to 2 seconds (on my mashine).

Change-Id: Ifb927e33b1f3364338ea4a303999d594fdecd24a
---
M repo/includes/ParserOutput/GeoDataDataUpdate.php
M repo/includes/ParserOutput/PageImagesDataUpdate.php
A repo/includes/Parsers/MediaWikiMonthNameProvider.php
A repo/includes/Parsers/MonthNameProvider.php
M repo/includes/Parsers/TimeParserFactory.php
A repo/tests/phpunit/includes/Parsers/MediaWikiMonthNameProviderTest.php
M repo/tests/phpunit/includes/Parsers/TimeFormatterParserRoundtripTest.php
M repo/tests/phpunit/includes/Parsers/TimeParserFactoryTest.php
8 files changed, 259 insertions(+), 96 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/57/249757/1

diff --git a/repo/includes/ParserOutput/GeoDataDataUpdate.php 
b/repo/includes/ParserOutput/GeoDataDataUpdate.php
index d484f83..798af83 100644
--- a/repo/includes/ParserOutput/GeoDataDataUpdate.php
+++ b/repo/includes/ParserOutput/GeoDataDataUpdate.php
@@ -55,6 +55,7 @@
         * @param PropertyDataTypeMatcher $propertyDataTypeMatcher
         * @param string[] $preferredPropertiesIds
         * @param string[] $globeUris
+        *
         * @throws RuntimeException
         */
        public function __construct(
@@ -163,7 +164,7 @@
 
        /**
         * @param CoordinatesOutput $coordinatesOutput
-        * @param string $key
+        * @param string $primaryCoordKey
         */
        private function addPrimaryCoordinate(
                CoordinatesOutput $coordinatesOutput,
diff --git a/repo/includes/ParserOutput/PageImagesDataUpdate.php 
b/repo/includes/ParserOutput/PageImagesDataUpdate.php
index 14782cd..3591102 100644
--- a/repo/includes/ParserOutput/PageImagesDataUpdate.php
+++ b/repo/includes/ParserOutput/PageImagesDataUpdate.php
@@ -177,9 +177,13 @@
         * @param ParserOutput $parserOutput
         */
        public function updateParserOutput( ParserOutput $parserOutput ) {
-               if ( $this->bestFileName !== null ) {
-                       // This property name is the only "soft dependency" on 
the PageImages extension.
-                       $parserOutput->setProperty( 'page_image', 
$this->bestFileName );
+               // This page property's name is the only "soft dependency" on 
the PageImages extension.
+               $propertyName = 'page_image';
+
+               if ( $this->bestFileName === null ) {
+                       $parserOutput->unsetProperty( $propertyName );
+               } else {
+                       $parserOutput->setProperty( $propertyName, 
$this->bestFileName );
                }
        }
 
diff --git a/repo/includes/Parsers/MediaWikiMonthNameProvider.php 
b/repo/includes/Parsers/MediaWikiMonthNameProvider.php
new file mode 100644
index 0000000..a0fdd48
--- /dev/null
+++ b/repo/includes/Parsers/MediaWikiMonthNameProvider.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Wikibase\Repo\Parsers;
+
+use Language;
+
+/**
+ * A MonthNameProvider using MediaWiki's Language object.
+ *
+ * @since 0.5
+ *
+ * @licence GNU GPL v2+
+ * @author Thiemo Mättig
+ */
+class MediaWikiMonthNameProvider implements MonthNameProvider {
+
+       /**
+        * @see getLocalizedMonthNames::getCanonicalMonthNames
+        *
+        * @param string $languageCode
+        *
+        * @return string[] Array mapping the month's numbers 1 to 12 to 
localized month names.
+        */
+       public function getLocalizedMonthNames( $languageCode ) {
+               $language = Language::factory( $languageCode );
+
+               $monthNames = array();
+
+               for ( $i = 1; $i <= 12; $i++ ) {
+                       $monthNames[$i] = $language->getMonthName( $i );
+               }
+
+               return $monthNames;
+       }
+
+       /**
+        * Creates a replacements array using information retrieved via 
MediaWiki's Language object.
+        * Takes full month names, genitive names and abbreviations into 
account.
+        *
+        * @see MonthNameProvider::getMonthNameReplacements
+        *
+        * @param string $languageCode
+        * @param string $baseLanguageCode
+        *
+        * @return string[] Array mapping localized month names (including full 
month names, genitive
+        * names and abbreviations) to the same month names in canonical 
English.
+        */
+       public function getMonthNameReplacements( $languageCode, 
$baseLanguageCode = 'en' ) {
+               $language = Language::factory( $languageCode );
+               $baseLanguage = Language::factory( $baseLanguageCode );
+
+               $replacements = array();
+
+               for ( $i = 1; $i <= 12; $i++ ) {
+                       $canonical = $baseLanguage->getMonthName( $i );
+
+                       $replacements[$language->getMonthName( $i )] = 
$canonical;
+                       $replacements[$language->getMonthNameGen( $i )] = 
$canonical;
+                       $replacements[$language->getMonthAbbreviation( $i )] = 
$canonical;
+               }
+
+               return $replacements;
+       }
+
+}
diff --git a/repo/includes/Parsers/MonthNameProvider.php 
b/repo/includes/Parsers/MonthNameProvider.php
new file mode 100644
index 0000000..eee6456
--- /dev/null
+++ b/repo/includes/Parsers/MonthNameProvider.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Wikibase\Repo\Parsers;
+
+/**
+ * @since 0.5
+ *
+ * @licence GNU GPL v2+
+ * @author Thiemo Mättig
+ */
+interface MonthNameProvider {
+
+       /**
+        * @param string $languageCode
+        *
+        * @return string[] Array mapping the month's numbers 1 to 12 to 
localized month names.
+        */
+       public function getLocalizedMonthNames( $languageCode );
+
+       /**
+        * @param string $languageCode
+        * @param string $baseLanguageCode
+        *
+        * @return string[] Array mapping localized month names (possibly 
including full month names,
+        * genitive names and abbreviations) to the same month names in a base 
language (usually
+        * canonical English).
+        */
+       public function getMonthNameReplacements( $languageCode, 
$baseLanguageCode = 'en' );
+
+}
diff --git a/repo/includes/Parsers/TimeParserFactory.php 
b/repo/includes/Parsers/TimeParserFactory.php
index 358dc82..dd4abe6 100644
--- a/repo/includes/Parsers/TimeParserFactory.php
+++ b/repo/includes/Parsers/TimeParserFactory.php
@@ -2,7 +2,6 @@
 
 namespace Wikibase\Repo\Parsers;
 
-use Language;
 use ValueParsers\CalendarModelParser;
 use ValueParsers\DispatchingValueParser;
 use ValueParsers\EraParser;
@@ -19,6 +18,8 @@
  * @licence GNU GPL v2+
  * @author Adam Shorland
  * @author Thiemo Mättig
+ *
+ * @todo move me to DataValues-time
  */
 class TimeParserFactory {
 
@@ -28,12 +29,23 @@
        private $options;
 
        /**
-        * @param ParserOptions|null $options
+        * @var MonthNameProvider
         */
-       public function __construct( ParserOptions $options = null ) {
+       private $monthNameProvider;
+
+       /**
+        * @param ParserOptions|null $options
+        * @param MonthNameProvider|null $monthNameProvider
+        */
+       public function __construct(
+               ParserOptions $options = null,
+               MonthNameProvider $monthNameProvider = null
+       ) {
                $this->options = $options ?: new ParserOptions();
+               $this->monthNameProvider = $monthNameProvider ?: new 
MediaWikiMonthNameProvider();
 
                $this->options->defaultOption( ValueParser::OPT_LANG, 'en' );
+
        }
 
        /**
@@ -81,36 +93,10 @@
                $replacements = array();
 
                if ( $languageCode !== $baseLanguageCode ) {
-                       $replacements = $this->getMwMonthNameReplacements( 
$languageCode, $baseLanguageCode );
+                       $replacements = 
$this->monthNameProvider->getMonthNameReplacements( $languageCode, 
$baseLanguageCode );
                }
 
                return new MonthNameUnlocalizer( $replacements );
-       }
-
-       /**
-        * Creates replacements for the MonthNameUnlocalizer using information 
retrieved via MediaWiki's
-        * Language object. Takes full month names, genitive names and 
abbreviations into account.
-        *
-        * @param string $languageCode
-        * @param string $baseLanguageCode
-        *
-        * @return string[]
-        */
-       private function getMwMonthNameReplacements( $languageCode, 
$baseLanguageCode ) {
-               $language = Language::factory( $languageCode );
-               $baseLanguage = Language::factory( $baseLanguageCode );
-
-               $replacements = array();
-
-               for ( $i = 1; $i <= 12; $i++ ) {
-                       $canonical = $baseLanguage->getMonthName( $i );
-
-                       $replacements[$language->getMonthName( $i )] = 
$canonical;
-                       $replacements[$language->getMonthNameGen( $i )] = 
$canonical;
-                       $replacements[$language->getMonthAbbreviation( $i )] = 
$canonical;
-               }
-
-               return $replacements;
        }
 
 }
diff --git 
a/repo/tests/phpunit/includes/Parsers/MediaWikiMonthNameProviderTest.php 
b/repo/tests/phpunit/includes/Parsers/MediaWikiMonthNameProviderTest.php
new file mode 100644
index 0000000..5b72e55
--- /dev/null
+++ b/repo/tests/phpunit/includes/Parsers/MediaWikiMonthNameProviderTest.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Wikibase\Repo\Tests\Parsers;
+
+use PHPUnit_Framework_TestCase;
+use Wikibase\Repo\Parsers\MediaWikiMonthNameProvider;
+
+/**
+ * @covers Wikibase\Repo\Parsers\MediaWikiMonthNameProvider
+ *
+ * @group ValueParsers
+ * @group WikibaseRepo
+ * @group Wikibase
+ * @group TimeParsers
+ *
+ * @licence GNU GPL v2+
+ * @author Thiemo Mättig
+ */
+class MediaWikiMonthNameProviderTest extends PHPUnit_Framework_TestCase {
+
+       /**
+        * @dataProvider monthNamesProvider
+        */
+       public function testGetLocalizedMonthNames( $languageCode ) {
+               $instance = new MediaWikiMonthNameProvider();
+               $actual = $instance->getLocalizedMonthNames( $languageCode );
+               $this->assertInternalType( 'array', $actual );
+               $this->assertContainsOnly( 'string', $actual );
+               $this->assertCount( 12, $actual );
+       }
+
+       public function monthNamesProvider() {
+               return array(
+                       array( 'en' ),
+                       array( 'de' ),
+               );
+       }
+
+       /**
+        * @dataProvider replacementsProvider
+        */
+       public function testGetMonthNameReplacements( $languageCode, 
$baseLanguageCode ) {
+               $instance = new MediaWikiMonthNameProvider();
+               $actual = $instance->getMonthNameReplacements( $languageCode, 
$baseLanguageCode );
+               $this->assertInternalType( 'array', $actual );
+               $this->assertContainsOnly( 'string', $actual );
+               $this->assertGreaterThanOrEqual( 12, count( $actual ) );
+       }
+
+       public function replacementsProvider() {
+               return array(
+                       array( 'en', 'de' ),
+                       array( 'de', 'en' ),
+               );
+       }
+
+}
diff --git 
a/repo/tests/phpunit/includes/Parsers/TimeFormatterParserRoundtripTest.php 
b/repo/tests/phpunit/includes/Parsers/TimeFormatterParserRoundtripTest.php
index 277e2dc..00296f2 100644
--- a/repo/tests/phpunit/includes/Parsers/TimeFormatterParserRoundtripTest.php
+++ b/repo/tests/phpunit/includes/Parsers/TimeFormatterParserRoundtripTest.php
@@ -24,6 +24,20 @@
  */
 class TimeFormatterParserRoundtripTest extends PHPUnit_Framework_TestCase {
 
+       private function newTimeParserFactory( ParserOptions $options = null ) {
+               $monthNameProvider = $this->getMock( 
'Wikibase\Repo\Parsers\MonthNameProvider' );
+               $monthNameProvider->expects( $this->any() )
+                       ->method( 'getMonthNameReplacements' )
+                       ->will( $this->returnValue( array(
+                               '8月' => 'August',
+                               'agosto' => 'August',
+                               'Augusti' => 'August',
+                               'Avgust' => 'August',
+                       ) ) );
+
+               return new TimeParserFactory( $options, $monthNameProvider );
+       }
+
        public function isoTimestampProvider() {
                return array(
                        // Going up the precision chain
@@ -60,7 +74,7 @@
         */
        public function testFormatterParserRoundtrip( TimeValue $expected ) {
                $formatter = new MwTimeIsoFormatter();
-               $factory = new TimeParserFactory();
+               $factory = $this->newTimeParserFactory();
                $parser = $factory->getTimeParser();
 
                $formatted = $formatter->format( $expected );
@@ -99,7 +113,7 @@
         * @dataProvider formattedTimeProvider
         */
        public function testParserFormatterRoundtrip( $expected ) {
-               $factory = new TimeParserFactory();
+               $factory = $this->newTimeParserFactory();
                $parser = $factory->getTimeParser();
                $formatter = new MwTimeIsoFormatter();
 
@@ -124,7 +138,7 @@
                        IsoTimestampParser::OPT_PRECISION => 
$timeValue->getPrecision(),
                        IsoTimestampParser::OPT_CALENDAR => 
$timeValue->getCalendarModel(),
                ) );
-               $factory = new TimeParserFactory( $parserOptions );
+               $factory = $this->newTimeParserFactory( $parserOptions );
                $parser = $factory->getTimeParser();
 
                $this->assertSame( $formatted, $formatter->format( $timeValue ) 
);
diff --git a/repo/tests/phpunit/includes/Parsers/TimeParserFactoryTest.php 
b/repo/tests/phpunit/includes/Parsers/TimeParserFactoryTest.php
index 44c4137..3db9e46 100644
--- a/repo/tests/phpunit/includes/Parsers/TimeParserFactoryTest.php
+++ b/repo/tests/phpunit/includes/Parsers/TimeParserFactoryTest.php
@@ -3,7 +3,6 @@
 namespace Wikibase\Repo\Tests\Parsers;
 
 use DataValues\TimeValue;
-use Language;
 use PHPUnit_Framework_TestCase;
 use ValueParsers\ParserOptions;
 use ValueParsers\ValueParser;
@@ -23,8 +22,28 @@
  */
 class TimeParserFactoryTest extends PHPUnit_Framework_TestCase {
 
+       private function newTimeParserFactory( $languageCode = 'en' ) {
+               $options = new ParserOptions();
+               $options->setOption( ValueParser::OPT_LANG, $languageCode );
+
+               $monthNameProvider = $this->getMock( 
'Wikibase\Repo\Parsers\MonthNameProvider' );
+               $monthNameProvider->expects( $this->any() )
+                       ->method( 'getMonthNameReplacements' )
+                       ->will( $this->returnCallback( function( $languageCode, 
$baseLanguageCode ) {
+                               $replacements = array();
+                               for ( $i = 1; $i <= 12; $i++ ) {
+                                       $canonical = $baseLanguageCode . 
'Month' . $i;
+                                       $replacements[$languageCode . 'Month' . 
$i] = $canonical;
+                                       $replacements[$languageCode . 'Month' . 
$i . 'Gen'] = $canonical;
+                               }
+                               return $replacements;
+                       } ) );
+
+               return new TimeParserFactory( $options, $monthNameProvider );
+       }
+
        public function testGetTimeParser() {
-               $factory = new TimeParserFactory();
+               $factory = $this->newTimeParserFactory();
                $parser = $factory->getTimeParser();
 
                $this->assertInstanceOf( 'ValueParsers\ValueParser', $parser );
@@ -34,9 +53,7 @@
         * @dataProvider validInputProvider
         */
        public function testParse( $value, TimeValue $expected, $languageCode ) 
{
-               $options = new ParserOptions();
-               $options->setOption( ValueParser::OPT_LANG, $languageCode );
-               $factory = new TimeParserFactory( $options );
+               $factory = $this->newTimeParserFactory( $languageCode );
                $parser = $factory->getTimeParser();
                $actual = $parser->parse( $value );
 
@@ -170,13 +187,13 @@
                        /**
                         * @see ValueFormatters\Test\MwTimeIsoFormatterTest
                         */
-                       '16 Augusti 2013' =>
+                       '16 laMonth8 2013' =>
                                array( '+2013-08-16T00:00:00Z', 
TimeValue::PRECISION_DAY, $gregorian, 'la' ),
-                       '16 Avgust, 2013' =>
+                       '16 kaaMonth8, 2013' =>
                                array( '+2013-08-16T00:00:00Z', 
TimeValue::PRECISION_DAY, $gregorian, 'kaa' ),
-                       '16 agosto 2013' =>
+                       '16 ptMonth8 2013' =>
                                array( '+2013-08-16T00:00:00Z', 
TimeValue::PRECISION_DAY, $gregorian, 'pt' ),
-                       '16 8月 2013' =>
+                       '16 yueMonth8 2013' =>
                                array( '+2013-08-16T00:00:00Z', 
TimeValue::PRECISION_DAY, $gregorian, 'yue' ),
                );
 
@@ -203,7 +220,7 @@
         * @expectedException \ValueParsers\ParseException
         */
        public function testParseThrowsException( $value ) {
-               $factory = new TimeParserFactory();
+               $factory = $this->newTimeParserFactory();
                $parser = $factory->getTimeParser();
 
                $parser->parse( $value );
@@ -245,9 +262,7 @@
         * @dataProvider localizedMonthNameProvider
         */
        public function testMonthNameUnlocalizer( $date, $languageCode, 
$expected ) {
-               $options = new ParserOptions();
-               $options->setOption( ValueParser::OPT_LANG, $languageCode );
-               $factory = new TimeParserFactory( $options );
+               $factory = $this->newTimeParserFactory( $languageCode );
                $unlocalizer = $factory->getMonthNameUnlocalizer();
 
                $this->assertEquals( $expected, $unlocalizer->unlocalize( $date 
) );
@@ -256,23 +271,21 @@
        public function localizedMonthNameProvider() {
                $testCases = array(
                        // Nominative month names.
-                       array( '1 Juli 2013', 'de', '1 July 2013' ),
-                       array( '1 Januarie 1999', 'af', '1 January 1999' ),
-                       array( '16 Jenna 1999', 'bar', '16 January 1999' ),
-                       array( '12 Jänner 2013', 'de-at', '12 January 2013' ),
+                       array( '1 deMonth7 2013', 'de', '1 enMonth7 2013' ),
+                       array( '1 afMonth1 1999', 'af', '1 enMonth1 1999' ),
+                       array( '16 barMonth1 1999', 'bar', '16 enMonth1 1999' ),
+                       array( '12 de-atMonth1 2013', 'de-at', '12 enMonth1 
2013' ),
 
                        // Genitive month names.
-                       array( '1 Julis 2013', 'de', '1 July 2013' ),
-                       array( '31 Decembris 2013', 'la', '31 December 2013' ),
-
-                       // Abbreviations.
-                       array( '1 Jan 1999', 'af', '1 January 1999' ),
-                       array( '1 Mär. 1999', 'de', '1 March 1999' ),
+                       array( '1 deMonth7Gen 2013', 'de', '1 enMonth7 2013' ),
+                       array( '31 laMonth12Gen 2013', 'la', '31 enMonth12 
2013' ),
+                       array( '1 afMonth1Gen 1999', 'af', '1 enMonth1 1999' ),
+                       array( '1 deMonth3Gen 1999', 'de', '1 enMonth3 1999' ),
 
                        // Nothing to do in English.
-                       array( '1 June 2013', 'en', '1 June 2013' ),
-                       array( '1 Jan 2013', 'en', '1 Jan 2013' ),
-                       array( '1 January 1999', 'en', '1 January 1999' ),
+                       array( '1 enMonth6 2013', 'en', '1 enMonth6 2013' ),
+                       array( '1 enMonth1 2013', 'en', '1 enMonth1 2013' ),
+                       array( '1 enMonth1 1999', 'en', '1 enMonth1 1999' ),
 
                        // No localized month name found.
                        array( '16 FooBarBarxxx 1999', 'bar', '16 FooBarBarxxx 
1999' ),
@@ -282,30 +295,30 @@
                        array( '16 Dezember 1999', 'la', '16 Dezember 1999' ),
 
                        // Replace the longest unlocalized substring first.
-                       array( 'Juli Januar', 'de', 'Juli January' ),
-                       array( 'Juli Mai', 'de', 'July Mai' ),
-                       array( 'Juli December', 'de', 'July December' ),
-                       array( 'July Dezember', 'de', 'July December' ),
-                       array( 'Januar Mär Dez', 'de', 'January Mär Dez' ),
+                       array( 'deMonth7 deMonth12', 'de', 'deMonth7 enMonth12' 
),
+                       array( 'deMonth12 deMonth7', 'de', 'enMonth12 deMonth7' 
),
+                       array( 'deMonth7 enMonth12', 'de', 'enMonth7 enMonth12' 
),
+                       array( 'enMonth7 deMonth12', 'de', 'enMonth7 enMonth12' 
),
+                       array( 'deMonth12 deMonth7 deMonth8', 'de', 'enMonth12 
deMonth7 deMonth8' ),
 
                        // Do not mess with already unlocalized month names.
-                       array( 'January', 'de', 'January' ),
-                       array( 'April', 'la', 'April' ),
-                       array( 'Dec', 'de', 'Dec' ),
-                       array( '15 March 44 BC', 'nrm', '15 March 44 BC' ),
-                       array( 'Juni June', 'de', 'Juni June' ),
-                       array( 'July Jul', 'de', 'July Jul' ),
+                       array( 'enMonth1', 'de', 'enMonth1' ),
+                       array( 'enMonth4', 'la', 'enMonth4' ),
+                       array( 'enMonth12', 'de', 'enMonth12' ),
+                       array( '15 enMonth3 44 BC', 'nrm', '15 enMonth3 44 BC' 
),
+                       array( 'deMonth6 enMonth6', 'de', 'deMonth6 enMonth6' ),
+                       array( 'enMonth7 deMonth7', 'de', 'enMonth7 deMonth7' ),
 
                        // But shortening is ok even if a substring looks like 
it's already unlocalized.
-                       array( 'Mayo', 'war', 'May' ),
-                       array( 'July Julis', 'de', 'July July' ),
+                       array( 'warMonth5Gen', 'war', 'enMonth5' ),
+                       array( 'enMonth7 deMonth7Gen', 'de', 'enMonth7 
enMonth7' ),
 
                        // Do not mess with strings that are clearly not a 
valid date.
-                       array( 'Juli Juli', 'de', 'Juli Juli' ),
+                       array( 'deMonth7 deMonth7', 'de', 'deMonth7 deMonth7' ),
 
                        // Word boundaries currently do not prevent 
unlocalization on purpose.
-                       array( 'Mai2013', 'de', 'May2013' ),
-                       array( 'Februarii', 'de', 'Februaryii' ),
+                       array( 'deMonth52013', 'de', 'enMonth52013' ),
+                       array( 'deMonth2ii', 'de', 'enMonth2ii' ),
 
                        // Capitalization is currently significant. This may 
need to depend on the languages.
                        array( '1 juli 2013', 'de', '1 juli 2013' ),
@@ -313,17 +326,13 @@
 
                // Loop through some other languages
                $languageCodes = array( 'war', 'ceb', 'uk', 'ru', 'de' );
-               $en = Language::factory( 'en' );
 
                foreach ( $languageCodes as $languageCode ) {
-                       $language = Language::factory( $languageCode );
-
                        for ( $i = 1; $i <= 12; $i++ ) {
-                               $expected = $en->getMonthName( $i );
+                               $expected = 'enMonth' . $i;
 
-                               $testCases[] = array( $language->getMonthName( 
$i ), $languageCode, $expected );
-                               $testCases[] = array( 
$language->getMonthNameGen( $i ), $languageCode, $expected );
-                               $testCases[] = array( 
$language->getMonthAbbreviation( $i ), $languageCode, $expected );
+                               $testCases[] = array( $languageCode . 'Month' . 
$i, $languageCode, $expected );
+                               $testCases[] = array( $languageCode . 'Month' . 
$i . 'Gen', $languageCode, $expected );
                        }
                }
 
@@ -334,11 +343,8 @@
         * @dataProvider localizedMonthName_withLanguageChainProvider
         */
        public function testMonthNameUnlocalizer_withLanguageChain( $date, 
array $languageCodes, $expected ) {
-               $options = new ParserOptions();
-
                foreach ( $languageCodes as $languageCode ) {
-                       $options->setOption( ValueParser::OPT_LANG, 
$languageCode );
-                       $factory = new TimeParserFactory( $options );
+                       $factory = $this->newTimeParserFactory( $languageCode );
                        $unlocalizer = $factory->getMonthNameUnlocalizer();
                        $date = $unlocalizer->unlocalize( $date );
                }
@@ -349,16 +355,16 @@
        public function localizedMonthName_withLanguageChainProvider() {
                return array(
                        // First language contains the word.
-                       array( 'Feb.', array( 'de', 'la' ), 'February' ),
+                       array( 'deMonth2', array( 'de', 'la' ), 'enMonth2' ),
 
                        // Second language contains the word.
-                       array( 'February', array( 'de', 'en' ), 'February' ),
-                       array( 'Februar', array( 'en', 'de' ), 'February' ),
-                       array( 'Feb', array( 'de', 'la' ), 'February' ),
-                       array( 'Jun', array( 'de', 'ms' ), 'June' ),
+                       array( 'enMonth2', array( 'de', 'en' ), 'enMonth2' ),
+                       array( 'deMonth2', array( 'en', 'de' ), 'enMonth2' ),
+                       array( 'laMonth2', array( 'de', 'la' ), 'enMonth2' ),
+                       array( 'msMonth6', array( 'de', 'ms' ), 'enMonth6' ),
 
                        // No language contains the word.
-                       array( 'Jun', array( 'de', 'la' ), 'Jun' ),
+                       array( 'enMonth6', array( 'de', 'la' ), 'enMonth6' ),
                );
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/249757
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb927e33b1f3364338ea4a303999d594fdecd24a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to