| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Rest\Handler\Helper; |
| 4 |
|
| 5 |
use MediaWiki\Rest\Handler\Helper\HtmlMessageOutputHelper; |
| 6 |
use MediaWikiIntegrationTestCase; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
class HtmlMessageOutputHelperTest extends MediaWikiIntegrationTestCase { |
| 13 |
private function newHelper( $page ): HtmlMessageOutputHelper { |
| 14 |
return new HtmlMessageOutputHelper( $page ); |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public function testGetHtml() { |
| 22 |
$page = $this->getNonexistingTestPage( 'MediaWiki:Logouttext' ); |
| 23 |
|
| 24 |
$helper = $this->newHelper( $page ); |
| 25 |
|
| 26 |
$this->assertSame( 0, $page->getLatest() ); |
| 27 |
|
| 28 |
$htmlresult = $helper->getHtml()->getRawText(); |
| 29 |
|
| 30 |
$this->assertStringContainsString( 'You are now logged out', $htmlresult ); |
| 31 |
|
| 32 |
$this->assertStringContainsString( '<html', $htmlresult ); |
| 33 |
$this->assertStringContainsString( 'content="en"', $htmlresult ); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public function testGetETag() { |
| 41 |
$page = $this->getNonexistingTestPage( 'MediaWiki:Logouttext' ); |
| 42 |
|
| 43 |
$helper = $this->newHelper( $page ); |
| 44 |
|
| 45 |
$etag = $helper->getETag(); |
| 46 |
|
| 47 |
$this->assertStringContainsString( '"message/', $etag ); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
public function testGetHtmlWithLanguageCode() { |
| 55 |
$page = $this->getNonexistingTestPage( 'MediaWiki:Logouttext/de' ); |
| 56 |
|
| 57 |
$helper = $this->newHelper( $page ); |
| 58 |
|
| 59 |
$this->assertSame( 0, $page->getLatest() ); |
| 60 |
|
| 61 |
$htmlresult = $helper->getHtml()->getRawText(); |
| 62 |
|
| 63 |
$this->assertStringContainsString( 'Du bist nun abgemeldet', $htmlresult ); |
| 64 |
|
| 65 |
$this->assertStringContainsString( '<html', $htmlresult ); |
| 66 |
$this->assertStringContainsString( 'content="de"', $htmlresult ); |
| 67 |
} |
| 68 |
} |