mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-11 14:06:19 +00:00
92e52d0bad
AutoConfig was used to set VE to call internal REST API endpoints exposed by the parsoid extension. With DirectParsoidClient available, this is no longer needed. NOTE: this causes all wikis that do not have a RESTbase backend configured to start using DirectParsoidClient. This is true in particular for officewiki and labswiki. Bug: T320704 Change-Id: Ia4c6184dd75a653c3202ea160b6605335f36f6eb
75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\VisualEditor\Tests;
|
|
|
|
use MediaWiki\Extension\VisualEditor\Hooks;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Extension\VisualEditor\Hooks
|
|
* @group Database
|
|
*/
|
|
class HooksTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideOnResourceLoaderGetConfigVars
|
|
*/
|
|
public function testOnResourceLoaderGetConfigVars( array $config, array $expected ) {
|
|
$this->overrideConfigValues( $config );
|
|
|
|
$vars = [];
|
|
Hooks::onResourceLoaderGetConfigVars( $vars );
|
|
|
|
$this->assertArrayHasKey( 'wgVisualEditorConfig', $vars );
|
|
$veConfig = $vars['wgVisualEditorConfig'];
|
|
|
|
foreach ( $expected as $name => $value ) {
|
|
$this->assertArrayHasKey( $name, $veConfig );
|
|
$this->assertSame( $value, $veConfig[$name] );
|
|
}
|
|
}
|
|
|
|
public function provideOnResourceLoaderGetConfigVars() {
|
|
// TODO: test a lot more config!
|
|
|
|
yield 'restbaseUrl: No VRS modules' => [
|
|
[
|
|
'VirtualRestConfig' => [ 'modules' => [] ],
|
|
'VisualEditorRestbaseURL' => 'parsoid-url',
|
|
'VisualEditorFullRestbaseURL' => 'full-parsoid-url',
|
|
],
|
|
[
|
|
'restbaseUrl' => false,
|
|
'fullRestbaseUrl' => false,
|
|
]
|
|
];
|
|
yield 'restbaseUrl: VRS modules available' => [
|
|
[
|
|
'VirtualRestConfig' => [ 'modules' => [
|
|
'parsoid' => true,
|
|
] ],
|
|
'VisualEditorRestbaseURL' => 'parsoid-url',
|
|
'VisualEditorFullRestbaseURL' => 'full-parsoid-url',
|
|
],
|
|
[
|
|
'restbaseUrl' => 'parsoid-url',
|
|
'fullRestbaseUrl' => 'full-parsoid-url',
|
|
]
|
|
];
|
|
yield 'restbaseUrl: VRS modules available, but no direct access URLs' => [
|
|
[
|
|
'VirtualRestConfig' => [ 'modules' => [
|
|
'parsoid' => true,
|
|
] ],
|
|
'VisualEditorRestbaseURL' => 'parsoid-url',
|
|
'VisualEditorFullRestbaseURL' => 'full-parsoid-url',
|
|
],
|
|
[
|
|
'restbaseUrl' => 'parsoid-url',
|
|
'fullRestbaseUrl' => 'full-parsoid-url',
|
|
]
|
|
];
|
|
}
|
|
|
|
}
|