2022-08-29 10:44:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\VisualEditor\Tests;
|
|
|
|
|
2022-09-04 09:00:14 +00:00
|
|
|
use MediaWiki\Extension\VisualEditor\DirectParsoidClient;
|
2022-08-29 10:44:06 +00:00
|
|
|
use MediaWiki\Extension\VisualEditor\VisualEditorParsoidClientFactory;
|
|
|
|
use MediaWiki\Http\HttpRequestFactory;
|
2022-10-19 12:43:26 +00:00
|
|
|
use MediaWiki\Permissions\Authority;
|
2023-01-16 13:11:20 +00:00
|
|
|
use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory;
|
2022-08-29 10:44:06 +00:00
|
|
|
use MediaWikiIntegrationTestCase;
|
2024-10-20 12:01:32 +00:00
|
|
|
use Wikimedia\Http\MultiHttpClient;
|
2022-08-29 10:44:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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 );
|
|
|
|
}
|
|
|
|
|
2024-02-20 10:27:15 +00:00
|
|
|
private function newClientFactory(): VisualEditorParsoidClientFactory {
|
2022-08-29 10:44:06 +00:00
|
|
|
$httpRequestFactory = $this->createNoOpMock( HttpRequestFactory::class, [ 'createMultiClient' ] );
|
|
|
|
$httpRequestFactory->method( 'createMultiClient' )->willReturn(
|
|
|
|
$this->createNoOpMock( MultiHttpClient::class )
|
|
|
|
);
|
|
|
|
|
|
|
|
return new VisualEditorParsoidClientFactory(
|
2022-11-18 19:46:23 +00:00
|
|
|
$this->createNoOpMock( PageRestHelperFactory::class )
|
2022-08-29 10:44:06 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-09-04 09:00:14 +00:00
|
|
|
* @covers ::createParsoidClient
|
2022-08-29 10:44:06 +00:00
|
|
|
*/
|
2023-07-10 07:57:45 +00:00
|
|
|
public function testGetClient() {
|
2022-10-19 12:43:26 +00:00
|
|
|
$authority = $this->createNoOpMock( Authority::class );
|
2022-08-29 10:44:06 +00:00
|
|
|
|
2023-08-30 14:45:38 +00:00
|
|
|
$factory = $this->newClientFactory();
|
2022-10-13 10:05:13 +00:00
|
|
|
|
2023-07-13 11:09:49 +00:00
|
|
|
$client = $factory->createParsoidClient( $authority );
|
2023-07-10 07:57:45 +00:00
|
|
|
$this->assertInstanceOf( DirectParsoidClient::class, $client );
|
2022-08-29 10:44:06 +00:00
|
|
|
}
|
|
|
|
}
|