mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 15:40:00 +00:00
Replace Action::getActionName by IContextSource::getActionName
Change-Id: Ica106d108f8930b93c9bbd4851d2915b40d7b343
This commit is contained in:
parent
e773704caa
commit
0ce9a922dd
|
@ -12,7 +12,7 @@
|
|||
"type": "editor",
|
||||
"license-name": "GPL-2.0-or-later",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.35.0"
|
||||
"MediaWiki": ">= 1.38.0"
|
||||
},
|
||||
"config": {
|
||||
"CodeMirrorEnableBracketMatching": {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace MediaWiki\Extension\CodeMirror;
|
||||
|
||||
use Action;
|
||||
use Config;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use OutputPage;
|
||||
|
@ -29,10 +28,9 @@ class Hooks {
|
|||
if ( !$userOptionsLookup->getOption( $out->getUser(), 'usebetatoolbar' ) ) {
|
||||
return false;
|
||||
}
|
||||
$context = $out->getContext();
|
||||
return in_array( Action::getActionName( $context ), [ 'edit', 'submit' ] ) &&
|
||||
return in_array( $out->getActionName(), [ 'edit', 'submit' ] ) &&
|
||||
// CodeMirror on textarea wikitext editors doesn't support RTL (T170001)
|
||||
!$context->getTitle()->getPageLanguage()->isRTL();
|
||||
!$out->getTitle()->getPageLanguage()->isRTL();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,22 +18,15 @@ class HookTest extends MediaWikiIntegrationTestCase {
|
|||
* @covers \MediaWiki\Extension\CodeMirror\Hooks::onBeforePageDisplay
|
||||
*/
|
||||
public function testOnBeforePageDisplay() {
|
||||
$wikiPage = new \WikiPage( \Title::makeTitle( NS_MAIN, __METHOD__ ) );
|
||||
$context = $this->createMock( \IContextSource::class );
|
||||
$context->method( 'getRequest' )->willReturn( new \FauxRequest( [ 'action' => 'edit' ] ) );
|
||||
$context->method( 'canUseWikiPage' )->willReturn( true );
|
||||
$context->method( 'getWikiPage' )->willReturn( $wikiPage );
|
||||
$context->method( 'getTitle' )->willReturn( $wikiPage->getTitle() );
|
||||
|
||||
$user = $this->createMock( \User::class );
|
||||
$userOptionsLookup = $this->createMock( UserOptionsLookup::class );
|
||||
$userOptionsLookup->method( 'getOption' )->willReturn( true );
|
||||
$this->setService( 'UserOptionsLookup', $userOptionsLookup );
|
||||
|
||||
$out = $this->createMock( \OutputPage::class );
|
||||
$out->method( 'getModules' )->willReturn( [] );
|
||||
$out->method( 'getContext' )->willReturn( $context );
|
||||
$out->method( 'getUser' )->willReturn( $user );
|
||||
$out->method( 'getUser' )->willReturn( $this->createMock( \User::class ) );
|
||||
$out->method( 'getActionName' )->willReturn( 'edit' );
|
||||
$out->method( 'getTitle' )->willReturn( \Title::makeTitle( NS_MAIN, __METHOD__ ) );
|
||||
$out->expects( $this->exactly( 2 ) )->method( 'addModules' );
|
||||
|
||||
Hooks::onBeforePageDisplay( $out, $this->createMock( \Skin::class ) );
|
||||
|
|
Loading…
Reference in a new issue