Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/67975
Change subject: Reordered GeoCoordinateValue constructor parameters ...................................................................... Reordered GeoCoordinateValue constructor parameters Moved "precision" parameter to before the globe. Change-Id: Ie70b8624ce3726fc1703cb4fc11abdf7ac0b2b3d --- M DataValues/includes/values/GeoCoordinateValue.php M DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php M ValueParsers/tests/includes/api/ApiParseValueTest.php 3 files changed, 42 insertions(+), 41 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues refs/changes/75/67975/1 diff --git a/DataValues/includes/values/GeoCoordinateValue.php b/DataValues/includes/values/GeoCoordinateValue.php index c574b9b..17a1d85 100644 --- a/DataValues/includes/values/GeoCoordinateValue.php +++ b/DataValues/includes/values/GeoCoordinateValue.php @@ -60,15 +60,6 @@ protected $altitude; /** - * The globe on which the location resides. - * - * @since 0.1 - * - * @var string|null - */ - protected $globe; - - /** * The precision of the coordinate. * * @since 0.1 @@ -78,17 +69,26 @@ protected $precision; /** + * The globe on which the location resides. + * + * @since 0.1 + * + * @var string|null + */ + protected $globe; + + /** * @since 0.1 * * @param float|int $latitude * @param float|int $longitude * @param float|int|null $altitude + * param float|int|null $precision * @param string|null $globe - * @param float|int|null $precision * * @throws InvalidArgumentException */ - public function __construct( $latitude, $longitude, $altitude = null, $globe = 'http://www.wikidata.org/entity/Q2', $precision = null ) { + public function __construct( $latitude, $longitude, $altitude = null, $precision = null, $globe = 'http://www.wikidata.org/entity/Q2' ) { // TODO: validate those values! if ( is_int( $latitude ) ) { $latitude = (float)$latitude; @@ -129,8 +129,8 @@ $this->latitude = $latitude; $this->longitude = $longitude; $this->altitude = $altitude; - $this->globe = $globe; $this->precision = $precision; + $this->globe = $globe; } /** @@ -155,8 +155,8 @@ * @throws InvalidArgumentException */ public function unserialize( $value ) { - list( $latitude, $longitude, $altitude, $globe, $precision ) = json_decode( $value ); - $this->__construct( $latitude, $longitude, $altitude, $globe, $precision ); + list( $latitude, $longitude, $altitude, $precision, $globe ) = json_decode( $value ); + $this->__construct( $latitude, $longitude, $altitude, $precision, $globe ); } /** @@ -227,17 +227,6 @@ } /** - * Returns the globe on which the location resides. - * - * @since 0.1 - * - * @return string|null - */ - public function getGlobe() { - return $this->globe; - } - - /** * Returns the precision of the coordinate. * * TODO: Introduce some constants holding the different precisions and document. Sync with JS. @@ -252,6 +241,17 @@ } /** + * Returns the globe on which the location resides. + * + * @since 0.1 + * + * @return string|null + */ + public function getGlobe() { + return $this->globe; + } + + /** * @see DataValue::getArrayValue * * @since 0.1 @@ -263,8 +263,8 @@ 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'altitude' => $this->altitude, + 'precision' => $this->precision, 'globe' => $this->globe, - 'precision' => $this->precision ); } @@ -283,8 +283,8 @@ $data['latitude'], $data['longitude'], $data['altitude'], - $data['globe'], - $data['precision'] + $data['precision'], + $data['globe'] ); } diff --git a/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php b/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php index a0e24aa..789eb66 100644 --- a/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php +++ b/DataValues/tests/phpunit/includes/values/GeoCoordinateValueTest.php @@ -104,19 +104,19 @@ $argLists[] = array( false, 42, 4.2, array() ); $argLists[] = array( false, 42, 4.2, 'foo' ); - $argLists[] = array( true, 42, 4.2, 9000.1, 'http://www.wikidata.org/entity/Q2' ); - $argLists[] = array( true, 42, 4.2, 9000.1, null ); - $argLists[] = array( true, 4.2, 42, 9000.1, 'terminus' ); - $argLists[] = array( true, 4.2, 42, 0, "Schar's World" ); - $argLists[] = array( true, -42, -4.2, -9000.1, 'coruscant' ); + $argLists[] = array( true, 42, 4.2, 9000.1, null, 'http://www.wikidata.org/entity/Q2' ); + $argLists[] = array( true, 42, 4.2, 9000.1, null, null ); + $argLists[] = array( true, 4.2, 42, 9000.1, null, 'terminus' ); + $argLists[] = array( true, 4.2, 42, 0, null, "Schar's World" ); + $argLists[] = array( true, -42, -4.2, -9000.1, null, 'coruscant' ); - $argLists[] = array( false, 42, 4.2, 9000.1, false ); - $argLists[] = array( false, 42, 4.2, 9000.1, true ); - $argLists[] = array( false, 42, 4.2, 9000.1, 42 ); - $argLists[] = array( false, 42, 4.2, 9000.1, 4.2 ); - $argLists[] = array( false, 42, 4.2, 9000.1, -1 ); - $argLists[] = array( false, 42, 4.2, 9000.1, 0 ); - $argLists[] = array( false, 42, 4.2, 9000.1, array() ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, false ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, true ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, 42 ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, 4.2 ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, -1 ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, 0 ); + $argLists[] = array( false, 42, 4.2, 9000.1, null, array() ); return $argLists; } @@ -168,7 +168,7 @@ * @param array $arguments */ public function testGetGlobe( GeoCoordinateValue $geoCoord, array $arguments ) { - $expected = array_key_exists( 3, $arguments ) ? $arguments[3] : 'http://www.wikidata.org/entity/Q2'; + $expected = array_key_exists( 4, $arguments ) ? $arguments[4] : 'http://www.wikidata.org/entity/Q2'; $actual = $geoCoord->getGlobe(); $this->assertTrue( diff --git a/ValueParsers/tests/includes/api/ApiParseValueTest.php b/ValueParsers/tests/includes/api/ApiParseValueTest.php index 98f8297..c974b1b 100644 --- a/ValueParsers/tests/includes/api/ApiParseValueTest.php +++ b/ValueParsers/tests/includes/api/ApiParseValueTest.php @@ -62,6 +62,7 @@ $this->assertArrayHasKey( 'latitude', $value, 'value has latitude key' ); $this->assertArrayHasKey( 'longitude', $value, 'value has longitude key' ); $this->assertArrayHasKey( 'altitude', $value, 'value has altitude key' ); + $this->assertArrayHasKey( 'precision', $value, 'value has precision key' ); $this->assertArrayHasKey( 'globe', $value, 'value has globe key' ); } } -- To view, visit https://gerrit.wikimedia.org/r/67975 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie70b8624ce3726fc1703cb4fc11abdf7ac0b2b3d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Henning Snater <henning.sna...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits