Merge "Bump wikimedia/parsoid to 0.21.0-a11"
[mediawiki.git] / tests / phpunit / mocks / MockWikiMapTrait.php
blob6ad6ac4e84b5547f6501f0b7375d937d7291b6f3
1 <?php
3 namespace MediaWiki\Tests;
5 use MediaWiki\Site\HashSiteStore;
6 use MediaWiki\Site\MediaWikiSite;
7 use MediaWiki\WikiMap\WikiMap;
9 /**
10 * Ensure WikiMap::getWiki returns a MediaWikiSite for the current wiki, for tests.
12 * @since 1.44
14 trait MockWikiMapTrait {
16 /**
17 * Override the SiteLookup service to include the current site.
19 * @return void
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 ] ) );