3 namespace MediaWiki\Tests
;
5 use MediaWiki\Site\HashSiteStore
;
6 use MediaWiki\Site\MediaWikiSite
;
7 use MediaWiki\WikiMap\WikiMap
;
10 * Ensure WikiMap::getWiki returns a MediaWikiSite for the current wiki, for tests.
14 trait MockWikiMapTrait
{
17 * Override the SiteLookup service to include the current site.
21 private function mockWikiMap() {
22 $currentSite = new MediaWikiSite();
23 $currentSite->setGlobalId( WikiMap
::getCurrentWikiId() );
24 $currentSite->setPath( MediaWikiSite
::PATH_PAGE
, 'https://example.com/wiki/$1' );
25 $this->setService( 'SiteLookup', new HashSiteStore( [ $currentSite ] ) );