Lucas Werkmeister (WMDE) has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/399381 )
Change subject: Normalize Metadata after merge ...................................................................... Normalize Metadata after merge Tests that use assertEquals() on metadata objects require that equivalent objects are member-by-member equal, so we need to replace blank merged metadata members with null ones so they’re equal to members of Metadata::blank(). Change-Id: I60a921ba6527336e745644fddc787875fb7faf1b --- M src/ConstraintCheck/Cache/Metadata.php M tests/phpunit/Cache/MetadataTest.php 2 files changed, 28 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints refs/changes/81/399381/1 diff --git a/src/ConstraintCheck/Cache/Metadata.php b/src/ConstraintCheck/Cache/Metadata.php index c9ff9a3..1c5509c 100644 --- a/src/ConstraintCheck/Cache/Metadata.php +++ b/src/ConstraintCheck/Cache/Metadata.php @@ -60,10 +60,32 @@ $ret = new self; $ret->cachingMetadata = CachingMetadata::merge( $cachingMetadatas ); $ret->dependencyMetadata = DependencyMetadata::merge( $dependencyMetadatas ); + $ret->normalize(); return $ret; } /** + * Replace blank metadata members with null, + * which is equivalent (the getters return new blank objects in that case). + * This is required for tests which use assertEquals() on metadata objects, + * so the tests don’t fail because one object has blank members and the other has null members. + */ + private function normalize() { + if ( + $this->cachingMetadata !== null && + $this->cachingMetadata == CachingMetadata::fresh() + ) { + $this->cachingMetadata = null; + } + if ( + $this->dependencyMetadata !== null && + $this->dependencyMetadata == DependencyMetadata::blank() + ) { + $this->dependencyMetadata = null; + } + } + + /** * @return CachingMetadata */ public function getCachingMetadata() { diff --git a/tests/phpunit/Cache/MetadataTest.php b/tests/phpunit/Cache/MetadataTest.php index e1fa48f..e7e97f6 100644 --- a/tests/phpunit/Cache/MetadataTest.php +++ b/tests/phpunit/Cache/MetadataTest.php @@ -84,4 +84,10 @@ ] ); } + public function testMerge_blankEquals() { + $m = Metadata::merge( [ Metadata::blank() ] ); + + $this->assertEquals( Metadata::blank(), $m ); + } + } -- To view, visit https://gerrit.wikimedia.org/r/399381 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I60a921ba6527336e745644fddc787875fb7faf1b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints Gerrit-Branch: master Gerrit-Owner: Lucas Werkmeister (WMDE) <lucas.werkmeis...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits