2018-07-03 21:25:01 +00:00
|
|
|
<?php
|
|
|
|
|
2022-02-06 15:13:05 +00:00
|
|
|
namespace MediaWiki\Extension\CodeMirror\Tests;
|
2018-07-03 21:25:01 +00:00
|
|
|
|
2023-10-10 19:23:03 +00:00
|
|
|
use ExtensionRegistry;
|
2024-03-01 00:36:39 +00:00
|
|
|
use Generator;
|
|
|
|
use Language;
|
2024-03-07 20:02:00 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
2024-03-01 00:36:39 +00:00
|
|
|
use MediaWiki\EditPage\EditPage;
|
2022-02-06 15:13:05 +00:00
|
|
|
use MediaWiki\Extension\CodeMirror\Hooks;
|
2023-10-10 19:23:03 +00:00
|
|
|
use MediaWiki\Extension\Gadgets\Gadget;
|
|
|
|
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
2023-10-11 19:53:54 +00:00
|
|
|
use MediaWiki\Output\OutputPage;
|
2023-09-19 17:59:29 +00:00
|
|
|
use MediaWiki\Request\WebRequest;
|
2023-08-19 04:14:07 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2023-11-29 12:38:30 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsLookup;
|
2023-10-11 19:53:54 +00:00
|
|
|
use MediaWiki\User\User;
|
2021-10-12 19:29:45 +00:00
|
|
|
use MediaWikiIntegrationTestCase;
|
2023-10-10 19:23:03 +00:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
2018-07-03 21:25:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group CodeMirror
|
2023-08-09 08:51:58 +00:00
|
|
|
* @group Database
|
2022-11-14 21:28:30 +00:00
|
|
|
* @coversDefaultClass \MediaWiki\Extension\CodeMirror\Hooks
|
2018-07-03 21:25:01 +00:00
|
|
|
*/
|
2021-10-12 19:29:45 +00:00
|
|
|
class HookTest extends MediaWikiIntegrationTestCase {
|
2020-10-08 08:18:20 +00:00
|
|
|
|
|
|
|
/**
|
2023-10-10 19:23:03 +00:00
|
|
|
* @covers ::shouldLoadCodeMirror
|
2024-03-01 00:36:39 +00:00
|
|
|
* @covers ::onEditPage__showEditForm_initial
|
2024-01-10 00:02:44 +00:00
|
|
|
* @covers ::onEditPage__showReadOnlyForm_initial
|
2023-09-19 17:59:29 +00:00
|
|
|
* @param bool $useCodeMirrorV6
|
|
|
|
* @param int $expectedAddModuleCalls
|
2024-03-01 00:36:39 +00:00
|
|
|
* @param string|null $expectedFirstModule
|
2024-01-10 00:02:44 +00:00
|
|
|
* @param bool $readOnly
|
2024-03-01 00:36:39 +00:00
|
|
|
* @dataProvider provideOnEditPageShowEditFormInitial
|
2020-10-08 08:18:20 +00:00
|
|
|
*/
|
2024-03-01 00:36:39 +00:00
|
|
|
public function testOnEditPageShowEditFormInitial(
|
2024-01-10 00:02:44 +00:00
|
|
|
bool $useCodeMirrorV6,
|
|
|
|
int $expectedAddModuleCalls,
|
|
|
|
?string $expectedFirstModule,
|
|
|
|
bool $readOnly = false
|
2023-09-19 17:59:29 +00:00
|
|
|
) {
|
|
|
|
$this->overrideConfigValues( [
|
|
|
|
'CodeMirrorV6' => $useCodeMirrorV6,
|
|
|
|
] );
|
2021-11-29 18:49:29 +00:00
|
|
|
$userOptionsLookup = $this->createMock( UserOptionsLookup::class );
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
$userOptionsLookup->method( 'getBoolOption' )->willReturn( true );
|
2020-10-08 08:18:20 +00:00
|
|
|
|
2023-10-10 19:23:03 +00:00
|
|
|
$out = $this->getMockOutputPage();
|
2020-10-08 08:18:20 +00:00
|
|
|
$out->method( 'getModules' )->willReturn( [] );
|
2024-01-17 16:21:42 +00:00
|
|
|
$isFirstCall = true;
|
2023-09-19 17:59:29 +00:00
|
|
|
$out->expects( $this->exactly( $expectedAddModuleCalls ) )
|
|
|
|
->method( 'addModules' )
|
2024-01-17 16:21:42 +00:00
|
|
|
->willReturnCallback( function ( $modules ) use ( $expectedFirstModule, &$isFirstCall ) {
|
2024-03-01 00:36:39 +00:00
|
|
|
if ( $isFirstCall && $modules !== null ) {
|
2024-01-17 16:21:42 +00:00
|
|
|
$this->assertSame( $expectedFirstModule, $modules );
|
|
|
|
}
|
|
|
|
$isFirstCall = false;
|
|
|
|
} );
|
2020-10-08 08:18:20 +00:00
|
|
|
|
2024-06-29 21:36:41 +00:00
|
|
|
$hooks = new Hooks( $userOptionsLookup, $this->getServiceContainer()->getMainConfig(), null );
|
2024-01-10 00:02:44 +00:00
|
|
|
$method = $readOnly ? 'onEditPage__showReadOnlyForm_initial' : 'onEditPage__showEditForm_initial';
|
|
|
|
$hooks->{$method}( $this->createMock( EditPage::class ), $out );
|
2023-09-19 17:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-03-01 00:36:39 +00:00
|
|
|
* @return Generator
|
2023-09-19 17:59:29 +00:00
|
|
|
*/
|
2024-03-01 00:36:39 +00:00
|
|
|
public static function provideOnEditPageShowEditFormInitial(): Generator {
|
2024-01-10 00:02:44 +00:00
|
|
|
// useCodeMirrorV6, expectedAddModuleCalls, expectedFirstModule, readOnly
|
2024-03-01 00:36:39 +00:00
|
|
|
yield 'CM5' => [ false, 2, 'ext.CodeMirror.WikiEditor' ];
|
2024-04-15 05:05:07 +00:00
|
|
|
yield 'CM6' => [ true, 1, 'ext.CodeMirror.v6.WikiEditor.init' ];
|
2024-01-10 00:02:44 +00:00
|
|
|
yield 'CM5 read-only' => [ false, 0, null, true ];
|
2024-04-15 05:05:07 +00:00
|
|
|
yield 'CM6 read-only' => [ true, 1, 'ext.CodeMirror.v6.WikiEditor.init', true ];
|
2020-10-08 08:18:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-03 21:25:01 +00:00
|
|
|
/**
|
2022-11-14 21:28:30 +00:00
|
|
|
* @covers ::onGetPreferences
|
2018-07-03 21:25:01 +00:00
|
|
|
*/
|
|
|
|
public function testPreferenceRegistered() {
|
|
|
|
$user = self::getTestUser()->getUser();
|
2024-03-06 15:59:33 +00:00
|
|
|
$context = RequestContext::getMain();
|
|
|
|
$context->setTitle( Title::newFromText( __METHOD__ ) );
|
2024-06-14 15:34:06 +00:00
|
|
|
$kinds = $this->getServiceContainer()->getPreferencesFactory()
|
|
|
|
->getResetKinds( $user, $context, [ 'usecodemirror' => 1 ] );
|
2018-07-03 21:25:01 +00:00
|
|
|
self::assertEquals( 'registered', $kinds['usecodemirror'] );
|
|
|
|
}
|
2023-10-10 19:23:03 +00:00
|
|
|
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
/**
|
|
|
|
* @covers ::onGetPreferences
|
|
|
|
*/
|
|
|
|
public function testOnGetPreferencces(): void {
|
|
|
|
$user = self::getTestUser()->getUser();
|
|
|
|
$userOptionsLookup = $this->getServiceContainer()->getUserOptionsLookup();
|
|
|
|
$config = $this->getServiceContainer()->getMainConfig();
|
|
|
|
|
|
|
|
// CodeMirror 5
|
|
|
|
$this->overrideConfigValues( [ 'CodeMirrorV6' => false ] );
|
2024-06-29 21:36:41 +00:00
|
|
|
$hook = new Hooks( $userOptionsLookup, $config, null );
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
$preferences = [];
|
|
|
|
$hook->onGetPreferences( $user, $preferences );
|
|
|
|
self::assertArrayHasKey( 'usecodemirror', $preferences );
|
|
|
|
self::assertArrayHasKey( 'usecodemirror-colorblind', $preferences );
|
|
|
|
self::assertArrayNotHasKey( 'usecodemirror-summary', $preferences );
|
|
|
|
self::assertSame( 'api', $preferences['usecodemirror']['type'] );
|
|
|
|
|
|
|
|
// CodeMirror 6
|
|
|
|
$this->overrideConfigValues( [ 'CodeMirrorV6' => true ] );
|
2024-06-29 21:36:41 +00:00
|
|
|
$hook = new Hooks( $userOptionsLookup, $config, null );
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
$preferences = [];
|
|
|
|
$hook->onGetPreferences( $user, $preferences );
|
|
|
|
self::assertArrayHasKey( 'usecodemirror', $preferences );
|
|
|
|
self::assertArrayHasKey( 'usecodemirror-colorblind', $preferences );
|
|
|
|
self::assertArrayHasKey( 'usecodemirror-summary', $preferences );
|
|
|
|
self::assertSame( 'toggle', $preferences['usecodemirror']['type'] );
|
|
|
|
}
|
|
|
|
|
2023-10-10 19:23:03 +00:00
|
|
|
/**
|
|
|
|
* @covers ::shouldLoadCodeMirror
|
|
|
|
* @dataProvider provideShouldLoadCodeMirror
|
2024-01-10 00:02:44 +00:00
|
|
|
* @param array $conds
|
2024-03-01 00:36:39 +00:00
|
|
|
* @param bool $expectation
|
2023-10-10 19:23:03 +00:00
|
|
|
*/
|
2024-01-10 00:02:44 +00:00
|
|
|
public function testShouldLoadCodeMirror( array $conds, bool $expectation ): void {
|
|
|
|
$conds = array_merge( [
|
|
|
|
'module' => null,
|
|
|
|
'gadget' => null,
|
|
|
|
'contentModel' => CONTENT_MODEL_WIKITEXT,
|
|
|
|
'useV6' => false,
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
'isRTL' => false,
|
|
|
|
'usecodemirror' => true,
|
|
|
|
'usebetatoolbar' => true,
|
2024-01-10 00:02:44 +00:00
|
|
|
], $conds );
|
2024-03-01 00:36:39 +00:00
|
|
|
$this->overrideConfigValues( [
|
2024-01-10 00:02:44 +00:00
|
|
|
'CodeMirrorV6' => $conds['useV6'],
|
2024-03-01 00:36:39 +00:00
|
|
|
] );
|
2024-01-10 00:02:44 +00:00
|
|
|
$out = $this->getMockOutputPage( $conds['contentModel'], $conds['isRTL'] );
|
|
|
|
$out->method( 'getModules' )->willReturn( $conds['module'] ? [ $conds['module'] ] : [] );
|
2023-10-10 19:23:03 +00:00
|
|
|
$userOptionsLookup = $this->createMock( UserOptionsLookup::class );
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
$userOptionsLookup->method( 'getBoolOption' )
|
|
|
|
->willReturnMap( [
|
|
|
|
[ $out->getUser(), 'usecodemirror', 0, $conds['usecodemirror'] ],
|
|
|
|
[ $out->getUser(), 'usebetatoolbar', 0, $conds['usebetatoolbar'] ]
|
|
|
|
] );
|
2023-10-10 19:23:03 +00:00
|
|
|
|
2024-01-10 00:02:44 +00:00
|
|
|
$extensionRegistry = $this->getMockExtensionRegistry( (bool)$conds['gadget'] );
|
2024-03-01 00:36:39 +00:00
|
|
|
$extensionRegistry->method( 'getAttribute' )
|
|
|
|
->with( 'CodeMirrorContentModels' )
|
|
|
|
->willReturn( [ CONTENT_MODEL_WIKITEXT ] );
|
2023-10-10 19:23:03 +00:00
|
|
|
|
2024-06-29 21:36:41 +00:00
|
|
|
$gadgetRepoMock = null;
|
2024-01-10 00:02:44 +00:00
|
|
|
if ( $conds['gadget'] ) {
|
2024-09-13 10:37:00 +00:00
|
|
|
$this->markTestSkippedIfExtensionNotLoaded( 'Gadgets' );
|
|
|
|
|
2023-10-10 19:23:03 +00:00
|
|
|
$gadgetMock = $this->createMock( Gadget::class );
|
|
|
|
$gadgetMock->expects( $this->once() )
|
|
|
|
->method( 'isEnabled' )
|
|
|
|
->willReturn( true );
|
|
|
|
$gadgetRepoMock = $this->createMock( GadgetRepo::class );
|
|
|
|
$gadgetRepoMock->expects( $this->once() )
|
|
|
|
->method( 'getGadget' )
|
|
|
|
->willReturn( $gadgetMock );
|
|
|
|
$gadgetRepoMock->expects( $this->once() )
|
|
|
|
->method( 'getGadgetIds' )
|
2024-01-10 00:02:44 +00:00
|
|
|
->willReturn( [ $conds['gadget'] ] );
|
2023-10-10 19:23:03 +00:00
|
|
|
}
|
|
|
|
|
2024-06-29 21:36:41 +00:00
|
|
|
$hooks = new Hooks( $userOptionsLookup, $this->getServiceContainer()->getMainConfig(), $gadgetRepoMock );
|
2023-10-10 19:23:03 +00:00
|
|
|
self::assertSame( $expectation, $hooks->shouldLoadCodeMirror( $out, $extensionRegistry ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-03-01 00:36:39 +00:00
|
|
|
* @return Generator
|
2023-10-10 19:23:03 +00:00
|
|
|
*/
|
2024-03-01 00:36:39 +00:00
|
|
|
public function provideShouldLoadCodeMirror(): Generator {
|
2024-01-10 00:02:44 +00:00
|
|
|
// [ conditions, expectation ]
|
|
|
|
yield [ [], true ];
|
|
|
|
yield [ [ 'module' => 'ext.codeEditor' ], false ];
|
|
|
|
yield [ [ 'gadget' => 'wikEd' ], false ];
|
|
|
|
yield [ [ 'contentModel' => CONTENT_FORMAT_CSS ], false ];
|
|
|
|
yield [ [ 'isRTL' => true ], false ];
|
|
|
|
yield [ [ 'isRTL' => true, 'useV6' => true ], true ];
|
CM6: Add syntax highlighting preference for users without WikiEditor
This adds the `ext.CodeMirror.v6.init` ResourceLoader module which
allows use of CodeMirror on `#wpTextbox1` without the use of WikiEditor
(the 'usebetatoolbar' preference). In order for users to opt-in to using
CodeMirror, we make the existing 'usecodemirror' option into a visible
preference. In addition, with two preferences related to CodeMirror, we
group them under a new heading 'Syntax highlighting'. More preferences
may be added later to this section following T359498.
When WikiEditor is not enabled, the layout of the action=edit page has
the textarea as a sibling to other visible content, like `.editOptions`.
Because of this, we can't simply append the CodeMirror DOM to the parent
like we were before, as that would put the visible editor beneath the
edit summary, Publish button, etc. Instead we rework the CodeMirror to
first add a wrapper around the textarea and use that as the parent. This
way, `.cm-editor` is always in the same place in the DOM as the native
textarea.
Line wrapping and focus/blur events are also moved to CodeMirror, as
these are needed when not using WikiEditor.
Bug: T190108
Change-Id: I4bc069e0d398aa7088e4f50bbd0ddda458b289c3
2024-03-26 20:40:13 +00:00
|
|
|
yield [ [ 'usebetatoolbar' => false ], false ];
|
|
|
|
yield [ [ 'usebetatoolbar' => false, 'useV6' => true ], true ];
|
|
|
|
yield [ [ 'usebetatoolbar' => false, 'usecodemirror' => false, 'useV6' => true ], false ];
|
|
|
|
yield [ [ 'usecodemirror' => false ], true ];
|
|
|
|
yield [ [ 'usecodemirror' => false, 'useV6' => true ], true ];
|
|
|
|
yield [ [ 'usecodemirror' => false, 'usebetatoolbar' => false, 'useV6' => true ], false ];
|
2023-10-10 19:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-03-01 00:36:39 +00:00
|
|
|
* @param string $contentModel
|
|
|
|
* @param bool $isRTL
|
2024-09-13 10:37:00 +00:00
|
|
|
* @return OutputPage&MockObject
|
2023-10-10 19:23:03 +00:00
|
|
|
*/
|
2024-03-01 00:36:39 +00:00
|
|
|
private function getMockOutputPage( string $contentModel = CONTENT_MODEL_WIKITEXT, bool $isRTL = false ) {
|
2023-10-10 19:23:03 +00:00
|
|
|
$out = $this->createMock( OutputPage::class );
|
2023-10-11 19:53:54 +00:00
|
|
|
$out->method( 'getUser' )->willReturn( $this->createMock( User::class ) );
|
2023-10-10 19:23:03 +00:00
|
|
|
$out->method( 'getActionName' )->willReturn( 'edit' );
|
2024-03-01 00:36:39 +00:00
|
|
|
$title = $this->createMock( Title::class );
|
|
|
|
$title->method( 'getContentModel' )->willReturn( $contentModel );
|
|
|
|
$language = $this->createMock( Language::class );
|
|
|
|
$language->method( 'isRTL' )->willReturn( $isRTL );
|
|
|
|
$title->method( 'getPageLanguage' )->willReturn( $language );
|
|
|
|
$out->method( 'getTitle' )->willReturn( $title );
|
2023-10-10 19:23:03 +00:00
|
|
|
$request = $this->createMock( WebRequest::class );
|
|
|
|
$request->method( 'getRawVal' )->willReturn( null );
|
|
|
|
$out->method( 'getRequest' )->willReturn( $request );
|
|
|
|
return $out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $gadgetsEnabled
|
2024-09-13 10:37:00 +00:00
|
|
|
* @return ExtensionRegistry&MockObject
|
2023-10-10 19:23:03 +00:00
|
|
|
*/
|
|
|
|
private function getMockExtensionRegistry( bool $gadgetsEnabled ) {
|
|
|
|
$mock = $this->createMock( ExtensionRegistry::class );
|
|
|
|
$mock->method( 'isLoaded' )
|
|
|
|
->with( 'Gadgets' )
|
|
|
|
->willReturn( $gadgetsEnabled );
|
|
|
|
return $mock;
|
|
|
|
}
|
2018-07-03 21:25:01 +00:00
|
|
|
}
|