wiki.techinc.nl/tests/phpunit/includes/content/MessageContentTest.php
daniel 54c70c3551 Deprecate Content::getNativeData, add TextContent::getText
getNativeData() is under-specified - callers can do nothing with the
value returned by getNativeData without knowing the concrete Content
class. And if they know the concrete class, they can and should use
a specialized getter instead, anyway.

Basically, getNativeData is overly generic, an example of polymorphism
done poorly. Let's fix it now.

Bug: T155582
Change-Id: Id2c61dcd38ab30416a25746e3680edb8791ae8e8
2019-01-16 11:57:50 -08:00

60 lines
1.4 KiB
PHP

<?php
/**
* @group ContentHandler
*/
class MessageContentTest extends MediaWikiLangTestCase {
public function testGetHtml() {
$msg = new Message( 'about' );
$cnt = new MessageContent( $msg );
$this->assertSame( $msg->parse(), $cnt->getHtml() );
}
public function testGetWikitext() {
$msg = new Message( 'about' );
$cnt = new MessageContent( $msg );
$this->assertSame( $msg->text(), $cnt->getWikitext() );
}
public function testGetMessage() {
$msg = new Message( 'about' );
$cnt = new MessageContent( $msg );
$this->assertEquals( $msg, $cnt->getMessage() );
}
public function testGetParserOutput() {
$msg = new Message( 'about' );
$cnt = new MessageContent( $msg );
$title = Title::makeTitle( NS_MEDIAWIKI, 'about' );
$this->assertSame( $msg->parse(), $cnt->getParserOutput( $title )->getText() );
}
public function testSerialize() {
$msg = new Message( 'about' );
$cnt = new MessageContent( $msg );
$this->assertSame( $msg->plain(), $cnt->serialize() );
}
public function testEquals() {
$msg1 = new Message( 'about' );
$cnt1 = new MessageContent( $msg1 );
$msg2 = new Message( 'about' );
$cnt2 = new MessageContent( $msg2 );
$msg3 = new Message( 'faq' );
$cnt3 = new MessageContent( $msg3 );
$cnt4 = new WikitextContent( $msg3->plain() );
$this->assertTrue( $cnt1->equals( $cnt2 ) );
$this->assertFalse( $cnt1->equals( $cnt3 ) );
$this->assertFalse( $cnt1->equals( $cnt4 ) );
}
}