mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-02 18:06:16 +00:00
4418b61894
I've verified that no other extension uses this code apart from VE and locally tested that with this patch, VE still works and nothing explodes. There parent patch takes care of making sure the mode is no longer injected and we now have just etags with no hacked in modes because we now use direct mode always. Bug: T341612 Change-Id: Ib1756bf60104467a3a34be9bbb06d8f63537e550
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\VisualEditor\Tests;
|
|
|
|
use MediaWiki\Config\ServiceOptions;
|
|
use MediaWiki\Extension\VisualEditor\DirectParsoidClient;
|
|
use MediaWiki\Extension\VisualEditor\VisualEditorParsoidClientFactory;
|
|
use MediaWiki\Http\HttpRequestFactory;
|
|
use MediaWiki\Permissions\Authority;
|
|
use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory;
|
|
use MediaWikiIntegrationTestCase;
|
|
use MultiHttpClient;
|
|
|
|
/**
|
|
* @coversDefaultClass \MediaWiki\Extension\VisualEditor\VisualEditorParsoidClientFactory
|
|
*/
|
|
class VisualEditorParsoidClientFactoryTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @covers ::__construct
|
|
*/
|
|
public function testGetVisualEditorParsoidClientFactory() {
|
|
$veParsoidClientFactory = $this->getServiceContainer()
|
|
->get( VisualEditorParsoidClientFactory::SERVICE_NAME );
|
|
|
|
$this->assertInstanceOf( VisualEditorParsoidClientFactory::class, $veParsoidClientFactory );
|
|
}
|
|
|
|
private function newClientFactory( array $optionValues ) {
|
|
$options = new ServiceOptions( VisualEditorParsoidClientFactory::CONSTRUCTOR_OPTIONS, $optionValues );
|
|
|
|
$httpRequestFactory = $this->createNoOpMock( HttpRequestFactory::class, [ 'createMultiClient' ] );
|
|
$httpRequestFactory->method( 'createMultiClient' )->willReturn(
|
|
$this->createNoOpMock( MultiHttpClient::class )
|
|
);
|
|
|
|
return new VisualEditorParsoidClientFactory(
|
|
$options,
|
|
$this->createNoOpMock( PageRestHelperFactory::class )
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @covers ::createParsoidClient
|
|
*/
|
|
public function testGetClient() {
|
|
$authority = $this->createNoOpMock( Authority::class );
|
|
|
|
$factory = $this->newClientFactory( [
|
|
VisualEditorParsoidClientFactory::ENABLE_COOKIE_FORWARDING => false,
|
|
VisualEditorParsoidClientFactory::DEFAULT_PARSOID_CLIENT_SETTING => 'direct',
|
|
] );
|
|
|
|
$client = $factory->createParsoidClient( $authority );
|
|
$this->assertInstanceOf( DirectParsoidClient::class, $client );
|
|
}
|
|
}
|