jenkins-bot has submitted this change and it was merged.
Change subject: Make Formatter/Parser tests more independent from
TimeFormatter/Parser classes
......................................................................
Make Formatter/Parser tests more independent from TimeFormatter/Parser classes
* Drop disabled test case.
* Drop unused options.
* Make the two tests that are not time related independend from the time
classes.
* Introduce alias for generic TimeParser class (same as in I76a85ba).
Change-Id: I89dae5664bfa037a4e449e5829dd37f56a854694
---
M lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php
M lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php
M lib/tests/phpunit/parsers/PhpDateTimeParserTest.php
M repo/tests/phpunit/includes/api/FormatSnakValueTest.php
4 files changed, 73 insertions(+), 64 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php
b/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php
index 538b1c4..ffb684e 100644
--- a/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php
+++ b/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php
@@ -3,10 +3,12 @@
namespace ValueFormatters\Test;
use DataValues\TimeValue;
+use MediaWikiTestCase;
use ValueFormatters\FormatterOptions;
use ValueFormatters\TimeFormatter;
use ValueFormatters\ValueFormatter;
use ValueParsers\ParserOptions;
+use ValueParsers\TimeParser as IsoTimestampParser;
use ValueParsers\ValueParser;
use Wikibase\Lib\MwTimeIsoFormatter;
use Wikibase\Lib\Parsers\TimeParser;
@@ -24,7 +26,7 @@
* @author Adam Shorland
* @author Thiemo Mättig
*/
-class MwTimeIsoFormatterTest extends \MediaWikiTestCase {
+class MwTimeIsoFormatterTest extends MediaWikiTestCase {
/**
* Returns an array of test parameters.
@@ -559,8 +561,8 @@
private function assertCanRoundTrip( $formattedTime, TimeValue
$timeValue, $languageCode ) {
$options = new ParserOptions( array(
ValueParser::OPT_LANG => $languageCode,
- \ValueParsers\TimeParser::OPT_PRECISION =>
$timeValue->getPrecision(),
- \ValueParsers\TimeParser::OPT_CALENDAR =>
$timeValue->getCalendarModel(),
+ IsoTimestampParser::OPT_PRECISION =>
$timeValue->getPrecision(),
+ IsoTimestampParser::OPT_CALENDAR =>
$timeValue->getCalendarModel(),
) );
$timeParser = new TimeParser( $options );
diff --git
a/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php
b/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php
index 970be2b..35e6cdc 100644
--- a/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php
+++ b/lib/tests/phpunit/formatters/WikibaseValueFormatterBuildersTest.php
@@ -12,7 +12,6 @@
use Title;
use ValueFormatters\FormatterOptions;
use ValueFormatters\StringFormatter;
-use ValueFormatters\TimeFormatter;
use ValueFormatters\ValueFormatter;
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdValue;
@@ -45,6 +44,7 @@
protected function setUp() {
parent::setUp();
+
$this->setMwGlobals( 'wgArticlePath', '/wiki/$1' );
}
@@ -191,28 +191,34 @@
'a month in 1920' => array(
SnakFormatter::FORMAT_HTML,
$this->newFormatterOptions(),
- new TimeValue( '+1920-05-01T00:00:00Z',
- 1 * 60 * 60, 0, 0,
+ new TimeValue(
+ '+1920-05-01T00:00:00Z',
+ 0, 0, 0,
TimeValue::PRECISION_MONTH,
- TimeFormatter::CALENDAR_GREGORIAN ),
+
'http://www.wikidata.org/entity/Q1985727'
+ ),
'/^May 1920$/'
),
'a gregorian day in 1520' => array(
SnakFormatter::FORMAT_HTML,
$this->newFormatterOptions(),
- new TimeValue( '+1520-05-01T00:00:00Z',
- 1 * 60 * 60, 0, 0,
+ new TimeValue(
+ '+1520-05-01T00:00:00Z',
+ 0, 0, 0,
TimeValue::PRECISION_DAY,
- TimeFormatter::CALENDAR_GREGORIAN ),
+
'http://www.wikidata.org/entity/Q1985727'
+ ),
'/^1 May 1520<sup
class="wb-calendar-name">Gregorian<\/sup>$/'
),
'a julian day in 1980' => array(
SnakFormatter::FORMAT_HTML,
$this->newFormatterOptions(),
- new TimeValue( '+1980-05-01T00:00:00Z',
- 1 * 60 * 60, 0, 0,
+ new TimeValue(
+ '+1980-05-01T00:00:00Z',
+ 0, 0, 0,
TimeValue::PRECISION_DAY,
- TimeFormatter::CALENDAR_JULIAN ),
+
'http://www.wikidata.org/entity/Q1985786'
+ ),
'/^1 May 1980<sup
class="wb-calendar-name">Julian<\/sup>$/'
),
'text in english' => array(
diff --git a/lib/tests/phpunit/parsers/PhpDateTimeParserTest.php
b/lib/tests/phpunit/parsers/PhpDateTimeParserTest.php
index 0dbd2c2..a33746a 100644
--- a/lib/tests/phpunit/parsers/PhpDateTimeParserTest.php
+++ b/lib/tests/phpunit/parsers/PhpDateTimeParserTest.php
@@ -4,7 +4,7 @@
use DataValues\TimeValue;
use ValueParsers\Test\StringValueParserTest;
-use ValueParsers\TimeParser;
+use ValueParsers\TimeParser as IsoTimestampParser;
use Wikibase\Lib\Parsers\EraParser;
use Wikibase\Lib\Parsers\PhpDateTimeParser;
@@ -224,7 +224,7 @@
array_key_exists( 2, $args ) ? $args[2] : 0,
array_key_exists( 3, $args ) ? $args[3] : 0,
array_key_exists( 4, $args ) ? $args[4] :
TimeValue::PRECISION_DAY,
- array_key_exists( 5, $args ) ? $args[5] :
TimeParser::CALENDAR_GREGORIAN
+ array_key_exists( 5, $args ) ? $args[5] :
IsoTimestampParser::CALENDAR_GREGORIAN
);
$argList[] = array( (string)$value, $expected );
}
diff --git a/repo/tests/phpunit/includes/api/FormatSnakValueTest.php
b/repo/tests/phpunit/includes/api/FormatSnakValueTest.php
index 231d286..ed1aeca 100644
--- a/repo/tests/phpunit/includes/api/FormatSnakValueTest.php
+++ b/repo/tests/phpunit/includes/api/FormatSnakValueTest.php
@@ -2,6 +2,7 @@
namespace Wikibase\Test\Api;
+use ApiTestCase;
use DataValues\DataValue;
use DataValues\StringValue;
use DataValues\TimeValue;
@@ -23,96 +24,96 @@
* @licence GNU GPL v2+
* @author Daniel Kinzler
*/
-class FormatSnakValueTest extends \ApiTestCase {
+class FormatSnakValueTest extends ApiTestCase {
protected function setUp() {
parent::setUp();
- $this->setMwGlobals( array(
- 'wgArticlePath' => '/wiki/$1'
- ) );
+ $this->setMwGlobals( 'wgArticlePath', '/wiki/$1' );
}
public function provideApiRequest() {
- $november11 = new TimeValue( '+2013-11-11T01:02:03Z',
- 1 * 60 * 60, 0, 0,
+ $november11 = new TimeValue(
+ '+2013-11-11T01:02:03Z',
+ 0, 0, 0,
TimeValue::PRECISION_DAY,
- TimeFormatter::CALENDAR_GREGORIAN );
+ 'http://acme.test'
+ );
- $november = new TimeValue( '+00000002013-11-10T00:00:00Z',
- 1 * 60 * 60, 0, 0,
+ $november = new TimeValue(
+ '+2013-11-10T00:00:00Z',
+ 0, 0, 0,
TimeValue::PRECISION_MONTH,
- TimeFormatter::CALENDAR_GREGORIAN );
+ 'http://acme.test'
+ );
$wordSeparator = wfMessage( 'word-separator' )->text();
$deletedItem = wfMessage( 'wikibase-deletedentity-item'
)->inLanguage( 'en' )->text();
return array(
- array( new StringValue( 'test' ),
+ array(
+ new StringValue( 'test' ),
null,
null,
null,
- '/^test$/' ),
-
- array( $november11,
+ '/^test$/'
+ ),
+ array(
+ $november11,
null,
null,
- array( TimeFormatter::OPT_LANG => 'en' ),
- '/^11 November 2013$/' ),
-
- array( $november,
+ null,
+ '/^11 November 2013$/'
+ ),
+ array(
+ $november,
null,
null,
- array( TimeFormatter::OPT_LANG => 'en' ),
- '/^November 2013$/' ),
-
- /* // TimeFormatter is currently bypassed; This test
can only work once we start using it again.
- array( $november11,
null,
- null,
- array(
- TimeFormatter::OPT_LANG => 'en',
- TimeFormatter::OPT_CALENDARNAMES =>
array( 'http://acme.org' => 'ACME' ),
- TimeFormatter::OPT_TIME_ISO_FORMATTER
=> null
- ),
- '/^\+2013-11-11T01:02:03Z (ACME)$/' ),
- */
-
- array( new StringValue( 'http://acme.test' ),
+ '/^November 2013$/'
+ ),
+ array(
+ new StringValue( 'http://acme.test' ),
'string',
SnakFormatter::FORMAT_PLAIN,
null,
- '@^http://acme\.test$@' ),
-
- array( new StringValue( 'http://acme.test' ),
+ '@^http://acme\.test$@'
+ ),
+ array(
+ new StringValue( 'http://acme.test' ),
'string',
SnakFormatter::FORMAT_WIKI,
null,
- '@^http://acme\.test$@' ),
-
- array( new StringValue( 'http://acme.test' ),
+ '@^http://acme\.test$@'
+ ),
+ array(
+ new StringValue( 'http://acme.test' ),
'url',
SnakFormatter::FORMAT_PLAIN,
null,
- '@^http://acme\.test$@' ),
-
- array( new StringValue( 'http://acme.test' ),
+ '@^http://acme\.test$@'
+ ),
+ array(
+ new StringValue( 'http://acme.test' ),
'url',
SnakFormatter::FORMAT_WIKI,
null,
- '@^http://acme\.test$@' ),
-
- array( new StringValue( 'example.jpg' ),
+ '@^http://acme\.test$@'
+ ),
+ array(
+ new StringValue( 'example.jpg' ),
'commonsMedia',
SnakFormatter::FORMAT_HTML,
null,
-
'@commons\.wikimedia\.org\/wiki\/File:Example\.jpg@' ),
-
- array( new EntityIdValue( new ItemId( 'Q2147483647' ) ),
+
'@commons\.wikimedia\.org\/wiki\/File:Example\.jpg@'
+ ),
+ array(
+ new EntityIdValue( new ItemId( 'Q2147483647' )
),
'wikibase-item',
SnakFormatter::FORMAT_HTML,
null,
- '/^Q2147483647' . $wordSeparator . '<span
class="wb-entity-undefinedinfo">\(' . preg_quote( $deletedItem, '/' ) .
'\)<\/span>$/' ),
+ '/^Q2147483647' . $wordSeparator . '<span
class="wb-entity-undefinedinfo">\(' . preg_quote( $deletedItem, '/' ) .
'\)<\/span>$/'
+ ),
// @TODO: Test an existing Item id
);
--
To view, visit https://gerrit.wikimedia.org/r/197877
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I89dae5664bfa037a4e449e5829dd37f56a854694
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits