Instead of creating a half-initialized helper and later calling ::init, provide all the information necessary for the helper in the constructor. This is facilitated by the fact that there already exists a factory class, PageRestHelperFactory, which holds all the services required. This affects: * HtmlOutputRendererHelper::init() * HtmlMessageOutputHelper::init() * HtmlInputTransformHelper::init() Change-Id: I1e1213597c6be012f2bc024c2b370c968ff3b472
49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Rest\Handler\Helper;
|
|
|
|
use MediaWiki\Permissions\Authority;
|
|
use MediaWiki\Rest\Handler\Helper\HtmlInputTransformHelper;
|
|
use MediaWiki\Rest\Handler\Helper\HtmlMessageOutputHelper;
|
|
use MediaWiki\Rest\Handler\Helper\HtmlOutputHelper;
|
|
use MediaWiki\Rest\Handler\Helper\HtmlOutputRendererHelper;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\Helper\PageRestHelperFactory
|
|
* @group Database
|
|
*/
|
|
class PageRestHelperFactoryTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\Helper\PageRestHelperFactory::newHtmlMessageOutputHelper
|
|
* @covers \MediaWiki\Rest\Handler\Helper\PageRestHelperFactory::newHtmlOutputRendererHelper
|
|
*/
|
|
public function testNewHtmlOutputHelpers() {
|
|
$page = $this->getNonexistingTestPage( __METHOD__ );
|
|
$helperFactory = $this->getServiceContainer()->getPageRestHelperFactory();
|
|
|
|
$helper = $helperFactory->newHtmlMessageOutputHelper( $page );
|
|
|
|
$this->assertInstanceOf( HtmlMessageOutputHelper::class, $helper );
|
|
$this->assertInstanceOf( HtmlOutputHelper::class, $helper );
|
|
|
|
$authority = $this->createNoOpMock( Authority::class );
|
|
$helper = $helperFactory->newHtmlOutputRendererHelper( $page, [], $authority );
|
|
|
|
$this->assertInstanceOf( HtmlOutputRendererHelper::class, $helper );
|
|
$this->assertInstanceOf( HtmlOutputHelper::class, $helper );
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\Helper\PageRestHelperFactory::newHtmlInputTransformHelper
|
|
*/
|
|
public function testNewHtmlInputTransformHelper() {
|
|
$page = $this->getNonexistingTestPage( __METHOD__ );
|
|
$helperFactory = $this->getServiceContainer()->getPageRestHelperFactory();
|
|
|
|
$helper = $helperFactory->newHtmlInputTransformHelper( [], $page, 'foo', [] );
|
|
|
|
$this->assertInstanceOf( HtmlInputTransformHelper::class, $helper );
|
|
}
|
|
}
|