Jeroen De Dauw has submitted this change and it was merged. Change subject: Fix EntityHandlerTest with the new serialization format ......................................................................
Fix EntityHandlerTest with the new serialization format Change-Id: I2f268584f78d854832de63a324c4c8813eca4b76 --- M repo/tests/phpunit/includes/content/EntityHandlerTest.php M repo/tests/phpunit/includes/content/ItemHandlerTest.php 2 files changed, 11 insertions(+), 9 deletions(-) Approvals: WikidataJenkins: Verified Jeroen De Dauw: Looks good to me, approved diff --git a/repo/tests/phpunit/includes/content/EntityHandlerTest.php b/repo/tests/phpunit/includes/content/EntityHandlerTest.php index 4cdc3a0..de28353 100644 --- a/repo/tests/phpunit/includes/content/EntityHandlerTest.php +++ b/repo/tests/phpunit/includes/content/EntityHandlerTest.php @@ -15,7 +15,6 @@ use Wikibase\InternalSerialization\SerializerFactory; use Wikibase\Lib\Serializers\LegacyInternalEntitySerializer; use Wikibase\Lib\Store\EntityRedirect; -use Wikibase\Lib\Store\EntityContentDataCodec; use Wikibase\Repo\WikibaseRepo; use Wikibase\SettingsArray; @@ -357,12 +356,16 @@ $legacySerializer = new LegacyInternalEntitySerializer(); $oldBlob = json_encode( $legacySerializer->serialize( $entity ) ); - // replace "entity":["item",7] with "entity":"q7" + // fake several old formats + $type = $entity->getType(); $id = $entity->getId()->getSerialization(); - $veryOldBlob = preg_replace( '/"entity":\["\w+",\d+\]/', '"entity":"' . strtolower( $id ) . '"', $oldBlob ); + // replace "type":"item","id":"q7" with "entity":["item",7] + $veryOldBlob = preg_replace( '/"type":"\w+","id":"\w\d+"/', '"entity":["' . strtolower( $type ) . '",' . substr( $id, 1 ) . ']', $oldBlob ); + // replace "entity":["item",7] with "entity":"q7" + $veryVeryOldBlob = preg_replace( '/"entity":\["\w+",\d+\]/', '"entity":"' . strtolower( $id ) . '"', $veryOldBlob ); - // sanity - if ( $oldBlob == $veryOldBlob ) { + // sanity (cannot compare $veryOldBlob and $oldBlob until we have the new serialization in place) + if ( $veryVeryOldBlob == $veryOldBlob /* || $veryOldBlob == $oldBlob */ ) { throw new RuntimeException( 'Failed to fake very old serialization format based on oldish serialization format.' ); } @@ -372,8 +375,9 @@ $newBlob = json_encode( $newSerializer->serialize( $entity ) ); return array( - 'old serialization / ancient id format' => array( $veryOldBlob, $newBlob ), - 'old serialization / new silly id format' => array( $oldBlob, $newBlob ), + 'old serialization / ancient id format' => array( $veryVeryOldBlob, $newBlob ), + 'old serialization / new silly id format' => array( $veryOldBlob, $newBlob ), + 'old serialization / old serializer format' => array( $oldBlob, $newBlob ), 'new serialization format, keep as is' => array( $newBlob, $newBlob ), ); } diff --git a/repo/tests/phpunit/includes/content/ItemHandlerTest.php b/repo/tests/phpunit/includes/content/ItemHandlerTest.php index cd21434..590850e 100644 --- a/repo/tests/phpunit/includes/content/ItemHandlerTest.php +++ b/repo/tests/phpunit/includes/content/ItemHandlerTest.php @@ -10,9 +10,7 @@ use Wikibase\EntityContent; use Wikibase\ItemContent; use Wikibase\ItemHandler; -use Wikibase\Lib\Store\EntityContentDataCodec; use Wikibase\Lib\Store\EntityRedirect; -use Wikibase\Repo\WikibaseRepo; use Wikibase\SettingsArray; /** -- To view, visit https://gerrit.wikimedia.org/r/153844 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2f268584f78d854832de63a324c4c8813eca4b76 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Bene <benestar.wikime...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits