Jeroen De Dauw has uploaded a new change for review. https://gerrit.wikimedia.org/r/80202
Change subject: Added testSerializeCompatibility test ...................................................................... Added testSerializeCompatibility test Change-Id: Id930a570fb36b6bfa8ab89f050a63c4641fdf69d --- A DataValues/src/GeoCoordinateValue.php M DataValues/tests/phpunit/GlobeCoordinateValueTest.php 2 files changed, 30 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues refs/changes/02/80202/1 diff --git a/DataValues/src/GeoCoordinateValue.php b/DataValues/src/GeoCoordinateValue.php new file mode 100644 index 0000000..a8142e2 --- /dev/null +++ b/DataValues/src/GeoCoordinateValue.php @@ -0,0 +1,10 @@ +<?php + +namespace DataValues; + +/** + * @deprecated, use GlobeCoordinateValue + */ +class GeoCoordinateValue extends GlobeCoordinateValue { + +} \ No newline at end of file diff --git a/DataValues/tests/phpunit/GlobeCoordinateValueTest.php b/DataValues/tests/phpunit/GlobeCoordinateValueTest.php index 1ea67cc..c6d224e 100644 --- a/DataValues/tests/phpunit/GlobeCoordinateValueTest.php +++ b/DataValues/tests/phpunit/GlobeCoordinateValueTest.php @@ -128,11 +128,11 @@ public function testArrayValueCompatibility() { // These serializations where generated using revision f91f65f989cc3ffacbe924012d8f5b574e0b710c - // getArrayValue + serialize + // The strings are the result of calling getArrayValue on the objects and then feeding this to serialize. - $simpleSerialization = 'a:5:{s:8:"latitude";d:-4.2000000000000002;s:9:"longitude";d:42;s:8:"altitude";N;s:9:"precision";d:0.01;s:5:"globe";s:4:"mars";}'; + $serialization = 'a:5:{s:8:"latitude";d:-4.2000000000000002;s:9:"longitude";d:42;s:8:"altitude";N;s:9:"precision";d:0.01;s:5:"globe";s:4:"mars";}'; - $arrayForm = unserialize( $simpleSerialization ); + $arrayForm = unserialize( $serialization ); $geoCoordinate = GlobeCoordinateValue::newFromArray( $arrayForm ); $this->assertEquals( -4.2, $geoCoordinate->getLatitude() ); @@ -140,9 +140,9 @@ $this->assertEquals( 0.01, $geoCoordinate->getPrecision() ); $this->assertEquals( 'mars', $geoCoordinate->getGlobe() ); - $simpleSerialization = 'a:5:{s:8:"latitude";d:-4.2000000000000002;s:9:"longitude";d:-42;s:8:"altitude";d:9001;s:9:"precision";d:1;s:5:"globe";s:33:"http://www.wikidata.org/entity/Q2";}'; + $serialization = 'a:5:{s:8:"latitude";d:-4.2000000000000002;s:9:"longitude";d:-42;s:8:"altitude";d:9001;s:9:"precision";d:1;s:5:"globe";s:33:"http://www.wikidata.org/entity/Q2";}'; - $arrayForm = unserialize( $simpleSerialization ); + $arrayForm = unserialize( $serialization ); $geoCoordinate = GlobeCoordinateValue::newFromArray( $arrayForm ); $this->assertEquals( -4.2, $geoCoordinate->getLatitude() ); @@ -151,6 +151,20 @@ $this->assertEquals( 'http://www.wikidata.org/entity/Q2', $geoCoordinate->getGlobe() ); } - // TODO: add compatibility test for using serialize directly + public function testSerializeCompatibility() { + // These serializations where generated using revision f91f65f989cc3ffacbe924012d8f5b574e0b710c + // The strings are the result of feeding the objects directly into PHPs serialize method. + + $geoCoordinate = unserialize( 'C:29:"DataValues\GeoCoordinateValue":27:{[-4.2,-42,null,0.01,"mars"]}' ); + $this->assertInstanceOf( $this->getClass(), $geoCoordinate ); + + $this->assertEquals( -4.2, $geoCoordinate->getLatitude() ); + $this->assertEquals( -42, $geoCoordinate->getLongitude() ); + $this->assertEquals( 0.01, $geoCoordinate->getPrecision() ); + $this->assertEquals( 'mars', $geoCoordinate->getGlobe() ); + + $geoCoordinate = unserialize( 'C:29:"DataValues\GeoCoordinateValue":27:{[-4.2,-42,9001,0.01,"mars"]}' ); + $this->assertInstanceOf( $this->getClass(), $geoCoordinate ); + } } -- To view, visit https://gerrit.wikimedia.org/r/80202 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id930a570fb36b6bfa8ab89f050a63c4641fdf69d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits