mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-23 22:03:28 +00:00
Use $this->getServiceContainer() in tests and update class names
Consistently use $this->getServiceContainer() instead of MediaWikiServices::getInstance() in tests. Also use namespaced classes * MediaWiki\Output\OutputPage instead of OutputPage and * MediaWiki\User\User instead of User. Change-Id: I0cc39ba6cc706bf01581687e440ef9fb4ad39d81
This commit is contained in:
parent
c0b01008a4
commit
6a37fedf73
|
@ -6,12 +6,12 @@ use ExtensionRegistry;
|
||||||
use MediaWiki\Extension\CodeMirror\Hooks;
|
use MediaWiki\Extension\CodeMirror\Hooks;
|
||||||
use MediaWiki\Extension\Gadgets\Gadget;
|
use MediaWiki\Extension\Gadgets\Gadget;
|
||||||
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\Output\OutputPage;
|
||||||
use MediaWiki\Request\WebRequest;
|
use MediaWiki\Request\WebRequest;
|
||||||
use MediaWiki\Title\Title;
|
use MediaWiki\Title\Title;
|
||||||
|
use MediaWiki\User\User;
|
||||||
use MediaWiki\User\UserOptionsLookup;
|
use MediaWiki\User\UserOptionsLookup;
|
||||||
use MediaWikiIntegrationTestCase;
|
use MediaWikiIntegrationTestCase;
|
||||||
use OutputPage;
|
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use RequestContext;
|
use RequestContext;
|
||||||
use Skin;
|
use Skin;
|
||||||
|
@ -47,7 +47,7 @@ class HookTest extends MediaWikiIntegrationTestCase {
|
||||||
->method( 'addModules' )
|
->method( 'addModules' )
|
||||||
->withConsecutive( [ $this->equalTo( $expectedFirstModule ) ] );
|
->withConsecutive( [ $this->equalTo( $expectedFirstModule ) ] );
|
||||||
|
|
||||||
( new Hooks( $userOptionsLookup, MediaWikiServices::getInstance()->getMainConfig() ) )
|
( new Hooks( $userOptionsLookup, $this->getServiceContainer()->getMainConfig() ) )
|
||||||
->onBeforePageDisplay( $out, $this->createMock( Skin::class ) );
|
->onBeforePageDisplay( $out, $this->createMock( Skin::class ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class HookTest extends MediaWikiIntegrationTestCase {
|
||||||
|
|
||||||
$hooks = new Hooks(
|
$hooks = new Hooks(
|
||||||
$userOptionsLookup,
|
$userOptionsLookup,
|
||||||
MediaWikiServices::getInstance()->getMainConfig()
|
$this->getServiceContainer()->getMainConfig()
|
||||||
);
|
);
|
||||||
self::assertSame( $expectation, $hooks->shouldLoadCodeMirror( $out, $extensionRegistry ) );
|
self::assertSame( $expectation, $hooks->shouldLoadCodeMirror( $out, $extensionRegistry ) );
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ class HookTest extends MediaWikiIntegrationTestCase {
|
||||||
*/
|
*/
|
||||||
private function getMockOutputPage() {
|
private function getMockOutputPage() {
|
||||||
$out = $this->createMock( OutputPage::class );
|
$out = $this->createMock( OutputPage::class );
|
||||||
$out->method( 'getUser' )->willReturn( $this->createMock( \User::class ) );
|
$out->method( 'getUser' )->willReturn( $this->createMock( User::class ) );
|
||||||
$out->method( 'getActionName' )->willReturn( 'edit' );
|
$out->method( 'getActionName' )->willReturn( 'edit' );
|
||||||
$out->method( 'getTitle' )->willReturn( Title::makeTitle( NS_MAIN, __METHOD__ ) );
|
$out->method( 'getTitle' )->willReturn( Title::makeTitle( NS_MAIN, __METHOD__ ) );
|
||||||
$request = $this->createMock( WebRequest::class );
|
$request = $this->createMock( WebRequest::class );
|
||||||
|
|
Loading…
Reference in a new issue