Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/277216
Change subject: Prevent ItemContentTest::newRedirect from leaking state
......................................................................
Prevent ItemContentTest::newRedirect from leaking state
This was creating real titles, thus leaking data into global
caches, like LinkCache.
Change-Id: Idf961c21926be09b9be68635ab919e42f0a4f768
---
M repo/tests/phpunit/includes/Content/ItemContentTest.php
1 file changed, 25 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/16/277216/1
diff --git a/repo/tests/phpunit/includes/Content/ItemContentTest.php
b/repo/tests/phpunit/includes/Content/ItemContentTest.php
index 4eae670..150e64e 100644
--- a/repo/tests/phpunit/includes/Content/ItemContentTest.php
+++ b/repo/tests/phpunit/includes/Content/ItemContentTest.php
@@ -68,9 +68,31 @@
* @return ItemContent
*/
private function newRedirect( ItemId $itemId, ItemId $targetId ) {
- // FIXME: Use the respective EntityHandler instead of going via
the global title lookup!
- $titleLookup =
WikibaseRepo::getDefaultInstance()->getEntityTitleLookup();
- $title = $titleLookup->getTitleForId( $targetId );
+ $nsLookup =
WikibaseRepo::getDefaultInstance()->getEntityNamespaceLookup();
+ $itemNs = $nsLookup->getEntityNamespace(
CONTENT_MODEL_WIKIBASE_ITEM );
+
+ $title = $this->getMock( Title::class );
+ $title->expects( $this->any() )
+ ->method( 'getFullText' )
+ ->will( $this->returnValue(
$targetId->getSerialization() ) );
+ $title->expects( $this->any() )
+ ->method( 'getText' )
+ ->will( $this->returnValue(
$targetId->getSerialization() ) );
+ $title->expects( $this->any() )
+ ->method( 'isRedirect' )
+ ->will( $this->returnValue( false ) );
+ $title->expects( $this->any() )
+ ->method( 'getNamespace' )
+ ->will( $this->returnValue( $itemNs ) );
+ $title->expects( $this->any() )
+ ->method( 'equals' )
+ ->will( $this->returnCallback( function( Title $other )
use ( $targetId ) {
+ // XXX: Ignores namespaces
+ return $other->getText() ===
$targetId->getSerialization();
+ } ) );
+ $title->expects( $this->any() )
+ ->method( 'getLinkURL' )
+ ->will( $this->returnValue( 'http://foo.bar/' .
$targetId->getSerialization() ) );
return ItemContent::newFromRedirect( new EntityRedirect(
$itemId, $targetId ), $title );
}
--
To view, visit https://gerrit.wikimedia.org/r/277216
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf961c21926be09b9be68635ab919e42f0a4f768
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits