This introduces an interface HtmlOutputHelper that is implemented by both HtmlMessageOutputHelper or HtmlOutputRendererHelper based on the page we're dealing with. Bug: T323558 Change-Id: I1fb8dcc5cc05ce3f32f3c1862b88045f1c8e612b
71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Rest\Helper;
|
|
|
|
use MediaWiki\Rest\Handler\HtmlMessageOutputHelper;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper
|
|
* @group Database
|
|
*/
|
|
class HtmlMessageOutputHelperTest extends MediaWikiIntegrationTestCase {
|
|
private function newHelper(): HtmlMessageOutputHelper {
|
|
return new HtmlMessageOutputHelper();
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper::init
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper::getHtml
|
|
*/
|
|
public function testGetHtml() {
|
|
$page = $this->getNonexistingTestPage( 'MediaWiki:Logouttext' );
|
|
|
|
$helper = $this->newHelper();
|
|
$helper->init( $page );
|
|
|
|
$this->assertSame( 0, $page->getLatest() );
|
|
|
|
$htmlresult = $helper->getHtml()->getRawText();
|
|
|
|
$this->assertStringContainsString( 'You are now logged out', $htmlresult );
|
|
// Check that we have a full HTML document in English
|
|
$this->assertStringContainsString( '<html', $htmlresult );
|
|
$this->assertStringContainsString( 'content="en"', $htmlresult );
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper::init
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper::getETag
|
|
*/
|
|
public function testGetETag() {
|
|
$page = $this->getNonexistingTestPage( 'MediaWiki:Logouttext' );
|
|
|
|
$helper = $this->newHelper();
|
|
$helper->init( $page );
|
|
|
|
$etag = $helper->getETag();
|
|
|
|
$this->assertStringContainsString( '"message/', $etag );
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper::init
|
|
* @covers \MediaWiki\Rest\Handler\HtmlMessageOutputHelper::getHtml
|
|
*/
|
|
public function testGetHtmlWithLanguageCode() {
|
|
$page = $this->getNonexistingTestPage( 'MediaWiki:Logouttext/de' );
|
|
|
|
$helper = $this->newHelper();
|
|
$helper->init( $page );
|
|
|
|
$this->assertSame( 0, $page->getLatest() );
|
|
|
|
$htmlresult = $helper->getHtml()->getRawText();
|
|
|
|
$this->assertStringContainsString( 'Du bist nun abgemeldet', $htmlresult );
|
|
// Check that we have a full HTML document in English
|
|
$this->assertStringContainsString( '<html', $htmlresult );
|
|
$this->assertStringContainsString( 'content="de"', $htmlresult );
|
|
}
|
|
}
|