[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Cleanup DateTimeValueCleanerTest
jenkins-bot has submitted this change and it was merged. Change subject: Cleanup DateTimeValueCleanerTest .. Cleanup DateTimeValueCleanerTest In this patch I'm not touching any of the test cases. This is pure refactoring to make the code easier to read and easier to work on in future patches. Bug: T146356 Change-Id: Ibee47dd1c9b1eaf2a4eaa94225d0acfa2476cc60 --- M repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php 1 file changed, 66 insertions(+), 51 deletions(-) Approvals: Smalyshev: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php b/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php index 6baa999..ec56642 100644 --- a/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php +++ b/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php @@ -20,91 +20,106 @@ class DateTimeValueCleanerTest extends \PHPUnit_Framework_TestCase { public function getDates() { - return array( + $greg = TimeValue::CALENDAR_GREGORIAN; + $jul = TimeValue::CALENDAR_JULIAN; + $year1m = TimeValue::PRECISION_YEAR1M; + $year = TimeValue::PRECISION_YEAR; + $month = TimeValue::PRECISION_MONTH; + + return [ // Gregorian - array( "+0002014-01-05T12:34:56Z", "http://www.wikidata.org/entity/Q1985727;, "2014-01-05T12:34:56Z" ), - array( "+0002014-01-05T12:34:56Z", "http://www.wikidata.org/entity/Q1985727;, "2014-01-01T12:34:56Z", - TimeValue::PRECISION_YEAR ), - array( "-200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "-0200-01-01T00:00:00Z" ), - array( "+200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0200-01-01T00:00:00Z" ), - array( "+200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0200-01-01T00:00:00Z", - TimeValue::PRECISION_YEAR ), - array( "+0200200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "200200-01-01T00:00:00Z" ), - array( "+9200200-05-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "9200200-01-01T00:00:00Z", - TimeValue::PRECISION_Ma ), - array( "+9200200-05-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "9200200-05-31T00:00:00Z" ), - array( "-0200200-05-22T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "-200200-05-22T00:00:00Z" ), - array( "-0200200-02-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "-200200-02-29T00:00:00Z" ), - array( "+200-02-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0200-02-28T00:00:00Z" ), - array( "+204-02-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0204-02-29T00:00:00Z" ), - array( "+0002204-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "2204-04-30T00:00:00Z" ), - array( "+0002204-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "2204-04-01T00:00:00Z", - TimeValue::PRECISION_MONTH ), - array( "+000-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, null ), - array( "-000-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, null ), + [ '+0002014-01-05T12:34:56Z', $greg, '2014-01-05T12:34:56Z' ], + [ '+0002014-01-05T12:34:56Z', $greg, '2014-01-01T12:34:56Z', $year ], + [ '-200-00-00T00:00:00Z', $greg, '-0200-01-01T00:00:00Z' ], + [ '+200-00-00T00:00:00Z', $greg, '0200-01-01T00:00:00Z' ], + [ '+200-00-00T00:00:00Z', $greg, '0200-01-01T00:00:00Z', $year ], + [ '+0200200-00-00T00:00:00Z', $greg, '200200-01-01T00:00:00Z' ], + [ '+9200200-05-31T00:00:00Z', $greg, '9200200-01-01T00:00:00Z', $year1m ], + [ '+9200200-05-31T00:00:00Z', $greg, '9200200-05-31T00:00:00Z' ], + [ '-0200200-05-22T00:00:00Z', $greg, '-200200-05-22T00:00:00Z' ], + [ '-0200200-02-31T00:00:00Z', $greg, '-200200-02-29T00:00:00Z' ], + [ '+200-02-31T00:00:00Z', $greg, '0200-02-28T00:00:00Z' ], + [ '+204-02-31T00:00:00Z', $greg, '0204-02-29T00:00:00Z' ], +
[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Cleanup DateTimeValueCleanerTest
Thiemo Mättig (WMDE) has uploaded a new change for review. https://gerrit.wikimedia.org/r/312214 Change subject: Cleanup DateTimeValueCleanerTest .. Cleanup DateTimeValueCleanerTest In this patch I'm not touching any of the test cases. This is pure refactoring to make the code easier to read and easier to work on in future patches. Bug: T146356 Change-Id: Ibee47dd1c9b1eaf2a4eaa94225d0acfa2476cc60 --- M repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php 1 file changed, 66 insertions(+), 51 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/14/312214/1 diff --git a/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php b/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php index 6baa999..ec56642 100644 --- a/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php +++ b/repo/tests/phpunit/includes/Rdf/DateTimeValueCleanerTest.php @@ -20,91 +20,106 @@ class DateTimeValueCleanerTest extends \PHPUnit_Framework_TestCase { public function getDates() { - return array( + $greg = TimeValue::CALENDAR_GREGORIAN; + $jul = TimeValue::CALENDAR_JULIAN; + $year1m = TimeValue::PRECISION_YEAR1M; + $year = TimeValue::PRECISION_YEAR; + $month = TimeValue::PRECISION_MONTH; + + return [ // Gregorian - array( "+0002014-01-05T12:34:56Z", "http://www.wikidata.org/entity/Q1985727;, "2014-01-05T12:34:56Z" ), - array( "+0002014-01-05T12:34:56Z", "http://www.wikidata.org/entity/Q1985727;, "2014-01-01T12:34:56Z", - TimeValue::PRECISION_YEAR ), - array( "-200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "-0200-01-01T00:00:00Z" ), - array( "+200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0200-01-01T00:00:00Z" ), - array( "+200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0200-01-01T00:00:00Z", - TimeValue::PRECISION_YEAR ), - array( "+0200200-00-00T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "200200-01-01T00:00:00Z" ), - array( "+9200200-05-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "9200200-01-01T00:00:00Z", - TimeValue::PRECISION_Ma ), - array( "+9200200-05-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "9200200-05-31T00:00:00Z" ), - array( "-0200200-05-22T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "-200200-05-22T00:00:00Z" ), - array( "-0200200-02-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "-200200-02-29T00:00:00Z" ), - array( "+200-02-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0200-02-28T00:00:00Z" ), - array( "+204-02-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "0204-02-29T00:00:00Z" ), - array( "+0002204-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "2204-04-30T00:00:00Z" ), - array( "+0002204-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, "2204-04-01T00:00:00Z", - TimeValue::PRECISION_MONTH ), - array( "+000-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, null ), - array( "-000-04-31T00:00:00Z", "http://www.wikidata.org/entity/Q1985727;, null ), + [ '+0002014-01-05T12:34:56Z', $greg, '2014-01-05T12:34:56Z' ], + [ '+0002014-01-05T12:34:56Z', $greg, '2014-01-01T12:34:56Z', $year ], + [ '-200-00-00T00:00:00Z', $greg, '-0200-01-01T00:00:00Z' ], + [ '+200-00-00T00:00:00Z', $greg, '0200-01-01T00:00:00Z' ], + [ '+200-00-00T00:00:00Z', $greg, '0200-01-01T00:00:00Z', $year ], + [ '+0200200-00-00T00:00:00Z', $greg, '200200-01-01T00:00:00Z' ], + [ '+9200200-05-31T00:00:00Z', $greg, '9200200-01-01T00:00:00Z', $year1m ], + [ '+9200200-05-31T00:00:00Z', $greg, '9200200-05-31T00:00:00Z' ], + [ '-0200200-05-22T00:00:00Z', $greg, '-200200-05-22T00:00:00Z' ], + [ '-0200200-02-31T00:00:00Z', $greg, '-200200-02-29T00:00:00Z' ], + [ '+200-02-31T00:00:00Z', $greg, '0200-02-28T00:00:00Z' ], + [